Interface: DataSource
Implement this interface and pass it to a FireCMS to connect it to your data source. A Firestore implementation of this interface can be found in useFirestoreDataSource
Methods​
checkUniqueField​
â–¸ checkUniqueField(path
, name
, value
, property
, entityId?
): Promise
<boolean
>
Check if the given property is unique in the given collection
Parameters​
Name | Type | Description |
---|---|---|
path | string | Collection path |
name | string | of the property |
value | any | |
property | ResolvedProperty | |
entityId? | string |
Returns​
Promise
<boolean
>
true
if there are no other fields besides the given entity
Defined in​
lib/src/types/datasource.ts:200
countEntities​
â–¸ countEntities(props
): Promise
<number
>
Count the number of entities in a collection
Parameters​
Name | Type |
---|---|
props | Object |
props.collection | EntityCollection <any , string , User > |
props.path | string |
Returns​
Promise
<number
>
Defined in​
lib/src/types/datasource.ts:216
deleteEntity​
â–¸ deleteEntity<M
>(entity
): Promise
<void
>
Delete an entity
Type parameters​
Name | Type |
---|---|
M | extends Record <string , any > = any |
Parameters​
Name | Type |
---|---|
entity | DeleteEntityProps <M > |
Returns​
Promise
<void
>
was the whole deletion flow successful
Defined in​
lib/src/types/datasource.ts:185
fetchCollection​
â–¸ fetchCollection<M
>(«destructured»
): Promise
<Entity
<M
>[]>
Fetch data from a collection
See
useCollectionFetch if you need this functionality implemented as a hook
Type parameters​
Name | Type |
---|---|
M | extends Record <string , any > = any |
Parameters​
Name | Type |
---|---|
«destructured» | FetchCollectionProps <M > |
Returns​
Promise
<Entity
<M
>[]>
Function to cancel subscription
Defined in​
lib/src/types/datasource.ts:91
fetchEntity​
â–¸ fetchEntity<M
>(«destructured»
): Promise
<undefined
| Entity
<M
>>
Retrieve an entity given a path and a collection
Type parameters​
Name | Type |
---|---|
M | extends Record <string , any > = any |
Parameters​
Name | Type |
---|---|
«destructured» | FetchEntityProps <M > |
Returns​
Promise
<undefined
| Entity
<M
>>
Defined in​
lib/src/types/datasource.ts:140
generateEntityId​
â–¸ generateEntityId(path
): string
Generate an id for a new entity
Parameters​
Name | Type |
---|---|
path | string |
Returns​
string
Defined in​
lib/src/types/datasource.ts:211
listenCollection​
â–¸ Optional
listenCollection<M
>(«destructured»
): () => void
Listen to a collection in a given path. If you don't implement this method
fetchCollection
will be used instead, with no real time updates.
See
useCollectionFetch if you need this functionality implemented as a hook
Type parameters​
Name | Type |
---|---|
M | extends Record <string , any > = any |
Parameters​
Name | Type |
---|---|
«destructured» | ListenCollectionProps <M > |
Returns​
fn
Function to cancel subscription
â–¸ (): void
Listen to a collection in a given path. If you don't implement this method
fetchCollection
will be used instead, with no real time updates.
See
useCollectionFetch if you need this functionality implemented as a hook
Returns​
void
Function to cancel subscription
Defined in​
lib/src/types/datasource.ts:119
listenEntity​
â–¸ Optional
listenEntity<M
>(«destructured»
): () => void
Get realtime updates on one entity.
Type parameters​
Name | Type |
---|---|
M | extends Record <string , any > = any |
Parameters​
Name | Type |
---|---|
«destructured» | ListenEntityProps <M > |
Returns​
fn
Function to cancel subscription
â–¸ (): void
Get realtime updates on one entity.
Returns​
void
Function to cancel subscription
Defined in​
lib/src/types/datasource.ts:156
saveEntity​
â–¸ saveEntity<M
>(«destructured»
): Promise
<Entity
<M
>>
Save entity to the specified path
Type parameters​
Name | Type |
---|---|
M | extends Record <string , any > = any |
Parameters​
Name | Type |
---|---|
«destructured» | SaveEntityProps <M > |
Returns​
Promise
<Entity
<M
>>