@firebase/database

  • Version 0.10.3
  • Published
  • 13.5 MB
  • 7 dependencies
  • Apache-2.0 license

Install

npm i @firebase/database
yarn add @firebase/database
pnpm add @firebase/database

Overview

This is the Firebase Realtime Database component of the Firebase JS SDK.

Index

Variables

variable ServerValue

const ServerValue: { TIMESTAMP: object; increment: (delta: number) => object };

    Functions

    function enableLogging

    enableLogging: (
    logger_?: boolean | ((a: string) => void),
    persistent?: boolean
    ) => void;
    • The implementation of Firebase.enableLogging (defined here to break dependencies)

      Parameter logger_

      A flag to turn on logging, or a custom logger

      Parameter persistent

      Whether or not to persist logging settings across refreshes

    function registerDatabase

    registerDatabase: (instance: any) => void;

      Classes

      class Database

      class Database implements FirebaseService, Compat<ExpDatabase> {}
      • Class representing a firebase database.

      constructor

      constructor(_delegate: any, app: any);
      • The constructor should not be called by users of our public API.

      property app

      readonly app: any;

        property INTERNAL

        INTERNAL: { delete: () => any };

          property ServerValue

          static readonly ServerValue: {
          TIMESTAMP: object;
          increment: (delta: number) => object;
          };

            method goOffline

            goOffline: () => void;

              method goOnline

              goOnline: () => void;

                method ref

                ref: { (path?: string): Reference; (path?: Reference): Reference };
                • Returns a reference to the root or to the path specified in the provided argument.

                  Parameter path

                  The relative string path or an existing Reference to a database location.

                  Returns

                  Firebase reference.

                  Throws

                  If a Reference is provided, throws if it does not belong to the same project.

                method refFromURL

                refFromURL: (url: string) => Reference;
                • Returns a reference to the root or the path specified in url. We throw a exception if the url is not in the same domain as the current repo.

                  Returns

                  Firebase reference.

                method useEmulator

                useEmulator: (
                host: string,
                port: number,
                options?: { mockUserToken?: EmulatorMockTokenOptions }
                ) => void;
                • Modify this instance to communicate with the Realtime Database emulator.

                  Note: This method must be called before performing any other operation.

                  Parameter host

                  the emulator host (ex: localhost)

                  Parameter port

                  the emulator port (ex: 8080)

                  Parameter

                  options.mockUserToken - the mock auth token to use for unit testing Security Rules

                class DataSnapshot

                class DataSnapshot implements Compat<ExpDataSnapshot> {}
                • Class representing a firebase data snapshot. It wraps a SnapshotNode and surfaces the public methods (val, forEach, etc.) we want to expose.

                constructor

                constructor(_database: Database, _delegate: any);

                  property key

                  readonly key: any;

                    property ref

                    readonly ref: Reference;

                      method child

                      child: (path: string) => DataSnapshot;
                      • Returns a DataSnapshot of the specified child node's contents.

                        Parameter path

                        Path to a child.

                        Returns

                        DataSnapshot for child node.

                      method exists

                      exists: () => boolean;
                      • Returns whether the snapshot contains a non-null value.

                        Returns

                        Whether the snapshot contains a non-null value, or is empty.

                      method exportVal

                      exportVal: () => unknown;
                      • Returns the snapshot contents as JSON, including priorities of node. Suitable for exporting the entire node contents.

                        Returns

                        JSON representation of the DataSnapshot contents, or null if empty.

                      method forEach

                      forEach: (action: (snapshot: DataSnapshot) => boolean | void) => boolean;
                      • Iterates through child nodes and calls the specified action for each one.

                        Parameter action

                        Callback function to be called for each child.

                        Returns

                        True if forEach was canceled by action returning true for one of the child nodes.

                      method getPriority

                      getPriority: () => string | number | null;
                      • Returns the priority of the object, or null if no priority was set.

                        Returns

                        The priority.

                      method getRef

                      getRef: () => Reference;
                      • Returns

                        The Firebase reference for the location this snapshot's data came from.

                      method hasChild

                      hasChild: (path: string) => boolean;
                      • Returns whether the snapshot contains a child at the specified path.

                        Parameter path

                        Path to a child.

                        Returns

                        Whether the child exists.

                      method hasChildren

                      hasChildren: () => boolean;
                      • Returns whether this DataSnapshot has children.

                        Returns

                        True if the DataSnapshot contains 1 or more child nodes.

                      method numChildren

                      numChildren: () => number;
                      • Returns the number of children for this DataSnapshot.

                        Returns

                        The number of children that this DataSnapshot contains.

                      method toJSON

                      toJSON: () => unknown;

                        method val

                        val: () => unknown;
                        • Retrieves the snapshot contents as JSON. Returns null if the snapshot is empty.

                          Returns

                          JSON representation of the DataSnapshot contents, or null if empty.

                        class OnDisconnect

                        class OnDisconnect implements Compat<ExpOnDisconnect> {}

                          constructor

                          constructor(_delegate: any);

                            method cancel

                            cancel: (onComplete?: (a: Error | null) => void) => Promise<void>;

                              method remove

                              remove: (onComplete?: (a: Error | null) => void) => Promise<void>;

                                method set

                                set: (value: unknown, onComplete?: (a: Error | null) => void) => Promise<void>;

                                  method setWithPriority

                                  setWithPriority: (
                                  value: unknown,
                                  priority: number | string | null,
                                  onComplete?: (a: Error | null) => void
                                  ) => Promise<void>;

                                    method update

                                    update: (
                                    objectToMerge: Indexable,
                                    onComplete?: (a: Error | null) => void
                                    ) => Promise<void>;

                                      class Query

                                      class Query implements Compat<ExpQuery> {}
                                      • A Query represents a filter to be applied to a firebase location. This object purely represents the query expression (and exposes our public API to build the query). The actual query logic is in ViewBase.js.

                                        Since every Firebase reference is a query, Firebase inherits from this object.

                                      constructor

                                      constructor(database: Database, _delegate: any);

                                        property database

                                        readonly database: Database;

                                          property ref

                                          readonly ref: Reference;

                                            method endAt

                                            endAt: (value?: number | string | boolean | null, name?: string | null) => Query;

                                              method endBefore

                                              endBefore: (
                                              value?: number | string | boolean | null,
                                              name?: string | null
                                              ) => Query;

                                                method equalTo

                                                equalTo: (value: number | string | boolean | null, name?: string) => Query;
                                                • Load the selection of children with exactly the specified value, and, optionally, the specified name.

                                                method get

                                                get: () => Promise<DataSnapshot>;
                                                • Get the server-value for this query, or return a cached value if not connected.

                                                method isEqual

                                                isEqual: (other: Query) => boolean;
                                                • Return true if this query and the provided query are equivalent; otherwise, return false.

                                                method limitToFirst

                                                limitToFirst: (limit: number) => Query;
                                                • Set a limit and anchor it to the start of the window.

                                                method limitToLast

                                                limitToLast: (limit: number) => Query;
                                                • Set a limit and anchor it to the end of the window.

                                                method off

                                                off: (
                                                eventType?: string,
                                                callback?: SnapshotCallback,
                                                context?: object | null
                                                ) => void;

                                                  method on

                                                  on: (
                                                  eventType: string,
                                                  callback: SnapshotCallback,
                                                  cancelCallbackOrContext?: object | ((a: Error) => unknown),
                                                  context?: object | null
                                                  ) => SnapshotCallback;

                                                    method once

                                                    once: (
                                                    eventType: string,
                                                    callback?: SnapshotCallback,
                                                    failureCallbackOrContext?: object | ((a: Error) => void),
                                                    context?: object | null
                                                    ) => Promise<DataSnapshot>;
                                                    • Attaches a listener, waits for the first event, and then removes the listener

                                                    method orderByChild

                                                    orderByChild: (path: string) => Query;
                                                    • Given a child path, return a new query ordered by the specified grandchild path.

                                                    method orderByKey

                                                    orderByKey: () => Query;
                                                    • Return a new query ordered by the KeyIndex

                                                    method orderByPriority

                                                    orderByPriority: () => Query;
                                                    • Return a new query ordered by the PriorityIndex

                                                    method orderByValue

                                                    orderByValue: () => Query;
                                                    • Return a new query ordered by the ValueIndex

                                                    method startAfter

                                                    startAfter: (
                                                    value?: number | string | boolean | null,
                                                    name?: string | null
                                                    ) => Query;

                                                      method startAt

                                                      startAt: (
                                                      value?: number | string | boolean | null,
                                                      name?: string | null
                                                      ) => Query;

                                                        method toJSON

                                                        toJSON: () => any;

                                                          method toString

                                                          toString: () => string;
                                                          • Returns

                                                            URL for this location.

                                                          class Reference

                                                          class Reference extends Query implements Compat<ExpReference> {}

                                                            constructor

                                                            constructor(database: Database, _delegate: any);
                                                            • Call options: new Reference(Repo, Path) or new Reference(url: string, string|RepoManager)

                                                              Externally - this is the firebase.database.Reference type.

                                                            property catch

                                                            catch: <TResult = never>(
                                                            onrejected?: (reason: any) => TResult | PromiseLike<TResult>
                                                            ) => Promise<Reference | TResult>;

                                                              property database

                                                              readonly database: Database;

                                                                property key

                                                                readonly key: string;

                                                                  property parent

                                                                  readonly parent: Reference;

                                                                    property root

                                                                    readonly root: Reference;

                                                                      property then

                                                                      then: <TResult1 = Reference, TResult2 = never>(
                                                                      onfulfilled?: (value: Reference) => TResult1 | PromiseLike<TResult1>,
                                                                      onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>
                                                                      ) => Promise<TResult1 | TResult2>;

                                                                        method child

                                                                        child: (pathString: string) => Reference;

                                                                          method getKey

                                                                          getKey: () => string | null;
                                                                          • Returns

                                                                            {?string}

                                                                          method getParent

                                                                          getParent: () => Reference | null;
                                                                          • Returns

                                                                            {?Reference}

                                                                          method getRoot

                                                                          getRoot: () => Reference;
                                                                          • Returns

                                                                            {!Reference}

                                                                          method onDisconnect

                                                                          onDisconnect: () => OnDisconnect;

                                                                            method push

                                                                            push: (value?: unknown, onComplete?: (a: Error | null) => void) => Reference;

                                                                              method remove

                                                                              remove: (onComplete?: (a: Error | null) => void) => Promise<unknown>;

                                                                                method set

                                                                                set: (
                                                                                newVal: unknown,
                                                                                onComplete?: (error: Error | null) => void
                                                                                ) => Promise<unknown>;

                                                                                  method setPriority

                                                                                  setPriority: (
                                                                                  priority: string | number | null,
                                                                                  onComplete?: (a: Error | null) => void
                                                                                  ) => Promise<unknown>;

                                                                                    method setWithPriority

                                                                                    setWithPriority: (
                                                                                    newVal: unknown,
                                                                                    newPriority: string | number | null,
                                                                                    onComplete?: (a: Error | null) => void
                                                                                    ) => Promise<unknown>;

                                                                                      method transaction

                                                                                      transaction: (
                                                                                      transactionUpdate: (currentData: unknown) => unknown,
                                                                                      onComplete?: (
                                                                                      error: Error | null,
                                                                                      committed: boolean,
                                                                                      dataSnapshot: DataSnapshot | null
                                                                                      ) => void,
                                                                                      applyLocally?: boolean
                                                                                      ) => Promise<TransactionResult>;

                                                                                        method update

                                                                                        update: (
                                                                                        values: object,
                                                                                        onComplete?: (a: Error | null) => void
                                                                                        ) => Promise<unknown>;

                                                                                          Package Files (5)

                                                                                          Dependencies (7)

                                                                                          Dev Dependencies (5)

                                                                                          Peer Dependencies (0)

                                                                                          No peer dependencies.

                                                                                          Badge

                                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@firebase/database.

                                                                                          • Markdown
                                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@firebase/database)
                                                                                          • HTML
                                                                                            <a href="https://www.jsdocs.io/package/@firebase/database"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>