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 | StringProperty | NumberProperty | BooleanProperty | TimestampProperty | GeopointProperty | ReferenceProperty <any > | MapProperty <{ [Key: string] : any ; }> | ArrayProperty <CMSType [], any > | |
entityId? | string |
Returns​
Promise
<boolean
>
true
if there are no other fields besides the given entity
Defined in​
deleteEntity​
â–¸ deleteEntity<M
>(__namedParameters
): Promise
<void
>
Delete an entity
Type parameters​
Name |
---|
M |
Parameters​
Name | Type |
---|---|
__namedParameters | DeleteEntityProps <M > |
Returns​
Promise
<void
>
was the whole deletion flow successful
Defined in​
fetchCollection​
â–¸ fetchCollection<M
>(__namedParameters
): Promise
<Entity
<M
>[]>
Fetch data from a collection
see
useCollectionFetch if you need this functionality implemented as a hook
Type parameters​
Name |
---|
M |
Parameters​
Name | Type |
---|---|
__namedParameters | FetchCollectionProps <M > |
Returns​
Promise
<Entity
<M
>[]>
Function to cancel subscription
Defined in​
fetchEntity​
â–¸ fetchEntity<M
>(__namedParameters
): Promise
<Entity
<M
>>
Retrieve an entity given a path and a schema
Type parameters​
Name |
---|
M |
Parameters​
Name | Type |
---|---|
__namedParameters | FetchEntityProps <M > |
Returns​
Promise
<Entity
<M
>>
Defined in​
listenCollection​
â–¸ Optional
listenCollection<M
>(__namedParameters
): () => void
Listen to a entities 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 |
---|
M |
Parameters​
Name | Type |
---|---|
__namedParameters | ListenCollectionProps <M > |
Returns​
fn
Function to cancel subscription
â–¸ (): void
Listen to a entities 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​
listenEntity​
â–¸ Optional
listenEntity<M
>(__namedParameters
): () => void
Get realtime updates on one entity.
Type parameters​
Name |
---|
M |
Parameters​
Name | Type |
---|---|
__namedParameters | ListenEntityProps <M > |
Returns​
fn
Function to cancel subscription
â–¸ (): void
Get realtime updates on one entity.
Returns​
void
Function to cancel subscription
Defined in​
saveEntity​
â–¸ saveEntity<M
>(__namedParameters
): Promise
<Entity
<M
>>
Save entity to the specified path
Type parameters​
Name |
---|
M |
Parameters​
Name | Type |
---|---|
__namedParameters | SaveEntityProps <M > |
Returns​
Promise
<Entity
<M
>>