@squidcloud/client
    Preparing search index...

    Class CollectionReference<T>

    Holds a reference to a data collection. A collection reference is a reference to a collection in a database. You can use it to read or write data to the collection. A collection can refer to a table in a relational database or a collection in a NoSQL database.

    Read more about collection references in the documentation.

    Type Parameters

    Index
    refId: string

    A string that uniquely identifies this collection reference.

    • Returns a document reference for the given document id. The document id is an object that maps every primary key of the collection (as defined in the Squid Console) to its value. There are a few exceptions, all of them for the built_in_db: 1 - String document id is only supported for the built_in_db when a schema was not defined. 2 - When a document id is not provided, one is generated. 3 - If the collection in the built_in_db does not have a schema, the document id must be provided as a string.

      Examples:

      // For a collection in the built_in_db that does not have a schema
      const docRef = collectionRef.doc('my-doc-id');
      const docRef = collectionRef.doc({id: my-doc-id'});

      // For a collection with a single primary key field called "id"
      const docRef = collectionRef.doc({id: 'my-doc-id'});

      // For a collection with a composite primary key
      const docRef = collectionRef.doc({id1: 'my-doc-id1', id2: 'my-doc-id2'});

      // For a collection from the `built_in_db` without a defined schema when an id is not provided
      const docRef = collectionRef.doc(); // The id is generated

      Parameters

      • OptionaldocId: DocIdOrDocIdObj

        The document id as an object for the different fields in the primary key or a string.

      Returns DocumentReference<T>

      A document reference for the given document id.

    • Inserts multiple documents into the collection.

      Parameters

      Returns Promise<void>

    • Creates a JoinQueryBuilder that can be used to query the collection Note that when using a join query, you have to provide an alias for the query and for every other query participating in the join.

      Type Parameters

      • A extends string

      Parameters

      • alias: A

        The alias for the query.

      Returns JoinQueryBuilder<Record<A, []>, Record<A, T>, A, A>

      A JoinQueryBuilder that can be used to query the collection and joins with other queries.

    • Performs or on a list of queries. All the queries need to be on the same collection. The result will be a merge of all the queries sorted by the same sort condition of the first query. Duplicate items will be removed.

      Parameters

      • ...builders: QueryBuilder<T>[]

        The list of query builders to merge. (A query builder can be returned from the query method).

      Returns SnapshotEmitter<DocumentReference<T>>

      A query builder that can be used to perform the or operation.

    • Creates a QueryBuilder that can be used to query the collection.

      Returns QueryBuilder<T>

      A QueryBuilder that can be used to query the collection.