Structures

The following structures are available globally.

  • A structure representing metadata for a collection in the database.

    This metadata includes the collection’s name, the indexes associated with it, and the partition key used for organizing the data.

    • Properties:
    • name: The name of the collection.
    • indexes: An array of strings representing the indexes defined for the collection.
    • partitionKey: The key used to partition the data within the collection.
    See more

    Declaration

    Swift

    public struct CollectionMetadata : Codable
  • A structure that represents metrics for an index, providing insights into its usage and value distribution.

    • Properties:
      • accessCount: The number of times the index has been accessed. Defaults to 0.
      • lastAccess: The date and time when the index was last accessed. Defaults to .distantPast.
      • valueDistribution: A dictionary that tracks the distribution of values associated with the index, where the keys are the values and the values are their respective counts. Defaults to an empty dictionary.
    See more

    Declaration

    Swift

    public struct IndexMetrics
  • A generic structure representing a query for a specific type of data.

    This structure is used to build and execute queries on a collection of data stored in a database. It supports filtering data using predicates and key path predicates, and relies on a storage engine and query planner for execution.

    • Properties:

      • collection: The name of the collection being queried.
      • predicates: A list of field-based predicates used to filter the data.
      • storage: The storage engine responsible for managing the data.
      • planner: The query planner responsible for optimizing and executing the query.
      • keyPathPredicates: A list of key path-based predicates used to filter the data.
    See more

    Declaration

    Swift

    public struct Query<T> where T : Decodable, T : Encodable

    Parameters

    T

    The type of the data being queried. Must conform to Codable.

ExecutionPlan

  • A structure representing the execution plan for a query in the database.

    The ExecutionPlan provides details about how a query will be executed, including the collection being queried, the predicates applied, the estimated number of documents to scan, and the index strategy used.

    • Properties:

      • collection: The name of the collection being queried.
      • predicates: An array of tuples representing the query predicates, where each tuple contains a field name and a query operator.
      • estimatedDocsToScan: The estimated number of documents that will be scanned during the query execution.
      • shardsToSkip: The number of shards that can be skipped during query execution.
      • usedIndex: The name of the index used for the query, if any. If no index is used, this will be nil.
      • indexStrategy: The strategy used for indexing during query execution.
    • Conforms to:

      • CustomStringConvertible: Provides a human-readable description of the execution plan.
    See more

    Declaration

    Swift

    public struct ExecutionPlan : CustomStringConvertible

Query Operator

  • A structure responsible for planning and optimizing database queries.

    QueryPlanner provides statistical information about indexes and shards to assist in query execution planning.

    • Properties:
      • indexStats: A dictionary containing statistics for each index, where the key is the index name and the value is an IndexStat object.
      • shardStats: An array of ShardStat objects representing statistics for each shard in the database.
    See more

    Declaration

    Swift

    public struct QueryPlanner
  • A structure that represents metadata for a shard in the database.

    ShardMetadata contains information about the shard, such as the number of documents it holds, and timestamps for when it was created and last updated.

    • Properties:
      • documentCount: The total number of documents stored in the shard.
      • createdAt: The date and time when the shard was created.
      • updatedAt: The date and time when the shard was last updated.
    See more

    Declaration

    Swift

    public struct ShardMetadata : Codable
  • A structure representing metadata information for a shard.

    ShardMetadataInfo contains details about a specific shard, including its unique identifier, its location as a URL, and its associated metadata.

    • Properties:
      • id: A unique identifier for the shard.
      • url: The URL location of the shard.
      • metadata: The metadata associated with the shard.
    See more

    Declaration

    Swift

    public struct ShardMetadataInfo : Codable
  • A structure representing statistics for a collection in the database.

    CollectionStats provides detailed information about a specific collection, including its name, the number of shards, the total number of documents, the total size in bytes, and metadata about each shard.

    • Properties:
      • collectionName: The name of the collection.
      • numberOfShards: The number of shards associated with the collection.
      • totalDocuments: The total number of documents stored in the collection.
      • totalSizeInBytes: The total size of the collection in bytes.
      • shardDetails: An array of metadata information for each shard.
    See more

    Declaration

    Swift

    public struct CollectionStats : Codable
  • A structure representing global statistics for the database.

    GlobalStats provides an overview of the database’s state, including the total number of collections, documents, and the total size in bytes.

    • Properties:
      • totalCollections: The total number of collections in the database.
      • totalDocuments: The total number of documents across all collections.
      • totalSizeInBytes: The total size of the database in bytes.
    See more

    Declaration

    Swift

    public struct GlobalStats : Codable
  • A structure representing statistical information about an index.

    This structure provides details about the total number of entries, the count of unique values, the distribution of values, and access-related metadata for an index.

    • Properties:
      • totalCount: The total number of entries in the index.
      • uniqueValuesCount: The number of unique values in the index.
      • valueDistribution: A dictionary mapping each unique value to its occurrence count.
      • accessCount: The number of times the index has been accessed.
      • lastAccess: The date and time when the index was last accessed.
    See more

    Declaration

    Swift

    public struct IndexStat
  • Represents statistics for a shard in the database.

    • Properties:
      • docCount: The total number of documents in the shard.
      • fieldRanges: A dictionary mapping field names to their respective minimum and maximum values. The values are represented as AnyHashable to allow for flexibility in data types.
    See more

    Declaration

    Swift

    public struct ShardStat