Pyric
Navigate

API reference

pyric-admin/database

10 published symbols from pyric-admin

Generated from the TypeScript declarations shipped at this import path.

Interfaces

Database

Properties

PropertyModifierType
appreadonlyunknown

Methods

getRules()
getRules(): Promise<string>;
Returns

Promise<string>

getRulesJSON()
getRulesJSON(): Promise<object>;
Returns

Promise<object>

goOffline()
goOffline(): void;
Returns

void

goOnline()
goOnline(): void;
Returns

void

ref()
ref(path?: string): Reference;
Parameters
ParameterType
path?string
Returns

Reference

refFromURL()
refFromURL(url: string): Reference;
Parameters
ParameterType
urlstring
Returns

Reference

setRules()
setRules(source: string | object): Promise<void>;
Parameters
ParameterType
sourcestring | object
Returns

Promise<void>


DataSnapshot

Properties

PropertyModifierType
keyreadonlystring
refreadonlyReference

Methods

child()
child(path: string): DataSnapshot;
Parameters
ParameterType
pathstring
Returns

DataSnapshot

exists()
exists(): boolean;
Returns

boolean

exportVal()
exportVal(): unknown;
Returns

unknown

forEach()
forEach(action: (child: DataSnapshot) => boolean | void): boolean;
Parameters
ParameterType
action(child: DataSnapshot) => boolean | void
Returns

boolean

getPriority()
getPriority(): string | number;
Returns

string | number

hasChild()
hasChild(path: string): boolean;
Parameters
ParameterType
pathstring
Returns

boolean

hasChildren()
hasChildren(children?: string[]): boolean;
Parameters
ParameterType
children?string[]
Returns

boolean

numChildren()
numChildren(): number;
Returns

number

toJSON()
toJSON(): unknown;
Returns

unknown

val()
val(): unknown;
Returns

unknown


OnDisconnect

Indexable

[key: string]: unknown

Reference

Indexable

[key: string]: unknown

Properties

PropertyModifierType
databasereadonlyDatabase
keyreadonlystring
parentreadonlyReference
refreadonlyReference
rootreadonlyReference

Methods

child()
child(path: string): Reference;
Parameters
ParameterType
pathstring
Returns

Reference

get()
get(): Promise<DataSnapshot>;
Returns

Promise<DataSnapshot>

off()
off(eventType?: EventType, callback?: (snapshot: DataSnapshot, previousChildKey?: string) => unknown): void;
Parameters
ParameterType
eventType?EventType
callback?(snapshot: DataSnapshot, previousChildKey?: string) => unknown
Returns

void

on()
on(
   eventType: EventType,
   callback: (snapshot: DataSnapshot, previousChildKey?: string) => unknown,
   cancelCallback?: (error: Error) => unknown): unknown;
Parameters
ParameterType
eventTypeEventType
callback(snapshot: DataSnapshot, previousChildKey?: string) => unknown
cancelCallback?(error: Error) => unknown
Returns

unknown

once()
once(
   eventType: EventType,
   successCallback?: (snapshot: DataSnapshot) => unknown,
failureCallback?: (error: Error) => unknown): Promise<DataSnapshot>;
Parameters
ParameterType
eventTypeEventType
successCallback?(snapshot: DataSnapshot) => unknown
failureCallback?(error: Error) => unknown
Returns

Promise<DataSnapshot>

push()
push(value?: unknown, onComplete?: (error: Error) => void): ThenableReference;
Parameters
ParameterType
value?unknown
onComplete?(error: Error) => void
Returns

ThenableReference

remove()
remove(onComplete?: (error: Error) => void): Promise<void>;
Parameters
ParameterType
onComplete?(error: Error) => void
Returns

Promise<void>

set()
set(value: unknown, onComplete?: (error: Error) => void): Promise<void>;
Parameters
ParameterType
valueunknown
onComplete?(error: Error) => void
Returns

Promise<void>

toString()
toString(): string;
Returns

string

update()
update(values: object, onComplete?: (error: Error) => void): Promise<void>;
Parameters
ParameterType
valuesobject
onComplete?(error: Error) => void
Returns

Promise<void>

Type Aliases

EventType

type EventType =
  | "value"
  | "child_added"
  | "child_changed"
  | "child_removed"
  | "child_moved";

Mirror-owned structural types for the implemented admin RTDB surface.


Query

type Query = Reference;

ThenableReference

type ThenableReference = Reference & PromiseLike<Reference>;

Variables

ServerValue

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

Mirror of firebase-admin/database’s ServerValue constant and sentinel constructors.

Type Declaration

increment()
readonly increment: (delta: number) => object;
Parameters
ParameterType
deltanumber
Returns

object

TIMESTAMP
readonly TIMESTAMP: object;

Functions

getDatabase()

function getDatabase(app?: SandboxAdminApp, _url?: string): Database;

Returns the AdminDatabase service for the supplied app.

Signature mirrors firebase-admin/database’s getDatabase(app?).

  • getDatabase() — default database for the DEFAULT app (resolved through pyric-admin/app’s registry, exactly like firebase-admin’s no-arg getDatabase(); throws app/no-app when no default app has been initialized). Works for local and remote sandbox apps.
  • getDatabase(app) — default database for the app.
  • getDatabase(app, url) — legacy Pyric-only compatibility form. New code should use the upstream-shaped getDatabaseWithUrl export.

The sandbox brand returns the local or remote Database backed by the per-Sandbox state described in the module-level docs.

Parameters

ParameterType
app?SandboxAdminApp
_url?string

Returns

Database


getDatabaseWithUrl()

function getDatabaseWithUrl(_url: string, app?: SandboxAdminApp): Database;

Returns the AdminDatabase service selected by an upstream-shaped database URL.

This is the exact firebase-admin/database argument order used by the Firebase Functions SDK: getDatabaseWithUrl(url, app?). The first Pyric Functions slice has one shared RTDB instance, so the URL selects that instance rather than creating a second sandbox database.

Parameters

ParameterType
_urlstring
app?SandboxAdminApp

Returns

Database