FrostApi
@frost-orm/frost-web / Exports / FrostApi
Class: FrostApi<T>
Type parameters
Name | Type |
---|---|
T | extends FrostObject |
Table of contents
Methods
- add
- delete
- findMany
- findOne
- getAddMap
- getDeleteMap
- getRelated
- getRelatedObservable
- getUpdateMap
- observeMany
- observeOne
- update
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
Warning: Changes to nested instances won't be applied
See
Parameters
Name | Type | Description |
---|---|---|
object | T | The 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
Name | Type | Description |
---|---|---|
object | T | The 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
Name | Type | Description |
---|---|---|
options | Object | options for the query |
options.include? | Exclude <KeysOfEntriesWithType <T , Function >, "serialize" | "getConnectedKeys" | "getAllConnectedKeys" | "flatten" >[] | see Include. |
...queryConstraints | QueryConstraint [] | 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
Name | Type | Description |
---|---|---|
id | string | The 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.
Warning: Changes to nested instances won't be applied
See
Parameters
Name | Type | Description |
---|---|---|
object | T | The 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
Parameters
Name | Type | Description |
---|---|---|
object | T | The 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
Name | Type | Description |
---|---|---|
object | any | The 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
Name | Type | Description |
---|---|---|
object | any | The 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? | ListenToNestedChanges | see 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
Warning: Changes to nested instances won't be applied
See
Parameters
Name | Type | Description |
---|---|---|
object | T | The 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
Name | Type | Description |
---|---|---|
options | Object | options for the observable |
options.debounceDuration? | number | in 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? | ListenToNestedChanges | see ListenToNestedChanges. |
...queryConstraints | QueryConstraint [] | 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
Name | Type | Default value | Description |
---|---|---|---|
id | string | undefined | The 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" >[] | undefined | see Include. |
listenToNestedChanges | ListenToNestedChanges | false | see 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
Warning: Changes to nested instances won't be applied
See
Parameters
Name | Type | Description |
---|---|---|
object | T | The 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
>