Skip to main content
Version: Annotations-V1.0.0

FrostApi

@frost-orm/frost-web / Exports / FrostApi

Class: FrostApi<T>

Type parameters

NameType
Textends FrostObject

Table of contents

Methods

Methods

add

add(object, connect?): Promise<{ id: any }>

inserts the new object with the new key from the push function or the key that was passed down with the object instance. also connects the instance depending on the connect parameter

caution

Warning: Changes to nested instances won't be applied

See

ConnectOptions.

Parameters

NameTypeDescription
objectTThe object instance containing the new changes
connect?Record<Exclude<KeysOfEntriesWithType<T, Function>, "serialize" | "getConnectedKeys" | "getAllConnectedKeys" | "flatten">, string | string[]>see ConnectOptions.

Returns

Promise<{ id: any }>

an object containing the update map and the new node id


delete

delete(object, disconnect?): Promise<void>

Removes the Object from the database and disconnects related objects depending on the disconnect parameter

See

Parameters

NameTypeDescription
objectTThe object instance to be deleted from the database (the object instance should be the one fetched from Frost or you can do it manually be constructing an instance)
disconnect?DisconnectOptions<T>see DisconnectOptions.

Returns

Promise<void>


findMany

findMany(options, ...queryConstraints): Promise<T[]>

Just like the query function in the firebaseDB, but the first parameter is options for relations then is spread parameter like query

Just like observeMany but with promises instead of observables.

See

Parameters

NameTypeDescription
optionsObjectoptions for the query
options.include?Exclude<KeysOfEntriesWithType<T, Function>, "serialize" | "getConnectedKeys" | "getAllConnectedKeys" | "flatten">[]see Include.
...queryConstraintsQueryConstraint[]see QueryConstraint.

Returns

Promise<T[]>

the query results with related objects that were given in the include parameter


findOne

findOne(id, include?): Promise<T>

Returns the object with the given id and containing the related instances with it (depending on the include parameter)

Just like observeOne but with promises instead of observables

See

Parameters

NameTypeDescription
idstringThe object that you want to get the related objects from. (doesn't have to be an instantiated object could be the data map that was fetched manually )
include?Exclude<KeysOfEntriesWithType<T, Function>, "serialize" | "getConnectedKeys" | "getAllConnectedKeys" | "flatten">[]see Include.

Returns

Promise<T>

the object instance of the given id with related objects that were given in the include parameter


getAddMap

getAddMap(object, connect?): Promise<{ id: string ; map: any }>

Returns a map containing the updates to the database that could be passed to firebaseDB update function. Also the map contains the new object with the new key from the push function or the key that was passed down with the object instance. also connects the instance depending on the connect parameter.

caution

Warning: Changes to nested instances won't be applied

See

ConnectOptions.

Parameters

NameTypeDescription
objectTThe object instance containing the new changes
connect?Record<Exclude<KeysOfEntriesWithType<T, Function>, "serialize" | "getConnectedKeys" | "getAllConnectedKeys" | "flatten">, string | string[]>see ConnectOptions.

Returns

Promise<{ id: string ; map: any }>

an object containing the update map and the new node id


getDeleteMap

getDeleteMap(object, disconnect?): Promise<{ map: any }>

Returns a map of the updates that could be passed to the updated function from firebaseDB if the map is applied it removes the Object from the database and disconnects related objects depending on the disconnect parameter

See

DisconnectOptions

Parameters

NameTypeDescription
objectTThe object instance to be deleted from the database (the object instance should be the one fetched from Frost or you can do it manually be constructing an instance)
disconnect?DisconnectOptions<T>see DisconnectOptions

Returns

Promise<{ map: any }>

an object containing the update map


getRelated

getRelated(object, include?): Promise<T>

Returns the object with the related instances with it (depending on the include parameter) Use this if you have an object instance without the related instances you want.

Same as getRelatedObservable but with promises instead of observables

See

Parameters

NameTypeDescription
objectanyThe object that you want to get the related objects from. (doesn't have to be an instantiated object could be the data map that was fetched manually )
include?Exclude<KeysOfEntriesWithType<T, Function>, "serialize" | "getConnectedKeys" | "getAllConnectedKeys" | "flatten">[]see Include.

Returns

Promise<T>

an object instance with related objects that were given in the include parameter


getRelatedObservable

getRelatedObservable(object, include?, listenToNestedChanges?): Observable<T>

Returns an observable of the object with the related instances with it (depending on the include parameter) Use this if you have an object instance without the related instances you want.

See

Parameters

NameTypeDescription
objectanyThe object that you want to get the related objects from. (doesn't have to be an instantiated object could be the data map that was fetched manually )
include?Exclude<KeysOfEntriesWithType<T, Function>, "serialize" | "getConnectedKeys" | "getAllConnectedKeys" | "flatten">[]see Include.
listenToNestedChanges?ListenToNestedChangessee ListenToNestedChanges.

Returns

Observable<T>

an Observable of the object instance with related objects that were given in the include parameter


getUpdateMap

getUpdateMap(object, connect?, disconnect?): Promise<{ map: any }>

Returns a map containing the updates that could be passed to firebaseDB update function

caution

Warning: Changes to nested instances won't be applied

See

Parameters

NameTypeDescription
objectTThe object instance containing the new changes
connect?Record<Exclude<KeysOfEntriesWithType<T, Function>, "serialize" | "getConnectedKeys" | "getAllConnectedKeys" | "flatten">, string | string[]>see ConnectOptions.
disconnect?DisconnectOptions<T>see DisconnectOptions.

Returns

Promise<{ map: any }>

an object containing the update map


observeMany

observeMany(options, ...queryConstraints): Observable<T[]>

Just like the query function in the firebaseDB, but with observables, also the first parameter is options for the observable then is spread parameter like query

See

Default Value

options.debounceDuration 500

Default Value

options.listenToNestedChanges false

Parameters

NameTypeDescription
optionsObjectoptions for the observable
options.debounceDuration?numberin Milliseconds. incase multiple changes happen to the query in short time, this will prevent the observable to emit too many times
options.include?Exclude<KeysOfEntriesWithType<T, Function>, "serialize" | "getConnectedKeys" | "getAllConnectedKeys" | "flatten">[]see Include.
options.listenToNestedChanges?ListenToNestedChangessee ListenToNestedChanges.
...queryConstraintsQueryConstraint[]see QueryConstraint.

Returns

Observable<T[]>

an Observable of the query results with related objects that were given in the include parameter


observeOne

observeOne(id, include?, listenToNestedChanges?): Observable<T>

Returns an observable of the object with the given id and containing the related instances with it (depending on the include parameter)

See

Default Value

listenToNestedChanges false

Parameters

NameTypeDefault valueDescription
idstringundefinedThe object that you want to get the related objects from. (doesn't have to be an instantiated object could be the data map that was fetched manually )
include?Exclude<KeysOfEntriesWithType<T, Function>, "serialize" | "getConnectedKeys" | "getAllConnectedKeys" | "flatten">[]undefinedsee Include.
listenToNestedChangesListenToNestedChangesfalsesee ListenToNestedChanges.

Returns

Observable<T>

an Observable of the object instance of the given id with related objects that were given in the include parameter


update

update(object, connect?, disconnect?): Promise<void>

preforms the updates on the object instance and dis/connects relations depending on the options

caution

Warning: Changes to nested instances won't be applied

See

Parameters

NameTypeDescription
objectTThe object instance containing the new changes
connect?Record<Exclude<KeysOfEntriesWithType<T, Function>, "serialize" | "getConnectedKeys" | "getAllConnectedKeys" | "flatten">, string | string[]>see ConnectOptions.
disconnect?DisconnectOptions<T>see DisconnectOptions.

Returns

Promise<void>