Oracle® Backend For Firebase JavaScript Namespace SDK Reference, Release 26.1.0
    Preparing search index...
    Oracle® Backend For Firebase JavaScript Namespace SDK Reference
    Release 26.1.0

    G48197-02

    CollectionReference - Represents a reference to a collection.

    Type Parameters

    • T = any

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    id: string
    oracledb: Oracledb
    parent: DocumentReference<any>
    path: string
    type: string

    Methods

    • Creates a AggregateQuery with aggregate operation of type sum or average.

      Parameters

      • obj: { [key: string]: any }

        Object containing aggregate operations { totalPopulation: oracledb.AggregateField.sum('population') }

      Returns AggregateQuery

      Returns a AggregateQuery instance.

      Throws an error if aggregate is used on a namedQuery.

    • Applies column selection to the query.

      Parameters

      • arr: string[]

        Array of column names.

      Returns Query<T>

      Returns a Query instance.

    • Creates a AggregateQuery with aggregate operation as count.

      Returns AggregateQuery

      Returns a AggregateQuery instance.

      Throws an error if count is used on a namedQuery.

    • Returns the DocumentReference for the document in the collection for the path.

      Parameters

      • OptionaldocPath: string

      Returns DocumentReference<T>

    • Creates and returns a new query that along with a where clause filters documents to end at the provided document (inclusive) or fieldvalue.

      Parameters

      • ...args: any[]

      Returns Query<T>

      Returns a Query instance.

      Throws an error if endAt is used on a namedQuery.

    • Creates and returns a new query that along with a where clause filters documents to end before the provided document (exclusive) or fieldvalue.

      Parameters

      • ...args: any[]

      Returns Query<T>

      Returns a Query instance.

      Throws an error if endBefore is used on a namedQuery.

    • Creates a vector similarity query for v2 queries.

      Parameters

      • field: string
      • query:
            | { sparse?: never; vector: number[] }
            | {
                sparse: {
                    dimension: number;
                    indices: number[];
                    type: "sparse";
                    values: number[];
                };
                vector?: never;
            }
      • Optionaloptions: { metric?: "COSINE" | "EUCLIDEAN" | "DOT"; threshold?: number; topK?: number }

      Returns Query<T>

      const q = colRef.findNearest(
      "EMB",
      { vector: [0.22, 0.93, -0.1] },
      { metric: "COSINE", topK: 10 }
      );
      const snap = await q.get();
      const qSparse = colRef.findNearest(
      "EMB",
      { sparse: { type: "sparse", dimension: 1000, indices: [2, 7, 900], values: [0.9, 0.3, 0.5] } },
      { metric: "DOT", topK: 5 }
      );
      const sparseSnap = await qSparse.get();
    • Executes the query and return the result in form of snapshot.

      Returns Promise<QuerySnapshot<T>>

    • Checks whether this CollectionReference is equal to the provided one.

      Parameters

      Returns boolean

      Returns true if both CollectionReference instances are the same.

      Throws an error if colref is not a CollectionReference instance.

    • Creates and returns a new query that applies a limit clause to the query. It returns the documents with a constraint on the number of documents to be returned.

      Parameters

      • limitValue: number

        The maximum number of items to return.

      Returns Query<T>

      Returns a Query instance.

      Throws an error if limit is used on a namedQuery.

    • Creates and returns a new query that applies a limit clause to the query. It returns the documents with a constraint on the number of documents to be returned. It returns the last matching documents.

      Parameters

      • limitValue: number

        The maximum number of items to return.

      Returns Query<T>

      Returns a Query instance.

      Throws an error if limitToLast is used on a namedQuery.

    • Attaches callback to be executed on QuerySnapshot events. This is related to real time listening where we are using long-polling by default.

      ( observer : { complete ?: ( ) => void ; error ?: ( error :
      OracledbError ) => void ; next ?: ( snapshot : QuerySnapshot => void ) )

      ( onNext : ( snapshot : QuerySnapshot < T > ) => void , onError ? : ( error : OracledbError ) => void , onCompletion ? : ( ) => void )

      Parameters

      • observer: {
            complete?: () => void;
            error?: (error: Error) => void;
            next?: (snapshot: QuerySnapshot<T>) => void;
        }

      Returns () => void

    • Creates and returns a Query that when executed returns documents sorted by the given field. If not specified, it sorts the values in ascending order.

      Parameters

      • fieldName: string | FieldPath

        Field name to apply order by on.

      • OptionaldirStr: "desc" | "asc"

        Direction or order by "asc" or "desc".

      Returns Query<T>

      • New Query instance.

      Throws an error if orderBy is used on a namedQuery.

    • Creates and returns a new query that along with a where clause filters documents to start after the provided document (exclusive) or fieldvalue.

      Parameters

      • ...args: any[]

      Returns Query<T>

      Returns a Query instance.

      Throws an error if startAfter is used on a namedQuery.

    • Creates and returns a new query that along with a where clause filters documents to start from the provided document (inclusive) or fieldvalue.

      Parameters

      • ...args: any[]

      Returns Query<T>

      Returns a Query instance.

      Throws an error if startAt is used on a namedQuery.

    • Creates and returns a new query with the additional conditions to filter data. It applies a where clause to the query.

      Parameters

      • field: string | FieldPath

        Field name.

      • opStr: string

        Operator to be used with where. "==", ">=", "<=", "<", ">", "in", "not-in", "like", "!=" (supported operators)

      • fieldValue: any

        Value to be used while applying operator.

      Returns Query<T>

      Returns a Query instance.

      Throws an error if where is used on a namedQuery.

    • Custom data converter, allowing to use user defined classes with database instance. When get is called on the query the results are returned after applying the converter. Passing null will remove the current converter.

      Type Parameters

      • U

      Parameters

      • converter: any

        Object with two functions "fromOracledb" and "toOracledb". fromOracledb will be used to convert the json objects to user defined classes and toOracledb will be used to convert from user defined classes to json objects.

      Returns Query<U>

      Query instance with converter.

    • Parameters

      • vectorSearch: any

      Returns Query<T>