Skip to main content

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#

NameTypeDescription
pathstringCollection path
namestringof the property
valueany
propertyStringProperty | NumberProperty | BooleanProperty | TimestampProperty | GeopointProperty | ReferenceProperty<any> | MapProperty<Object> | ArrayProperty<CMSType[], any>
entityId?string

Returns#

Promise<boolean>

true if there are no other fields besides the given entity

Defined in#

models/datasource.ts:199


deleteEntity#

deleteEntity<M>(__namedParameters): Promise<void>

Delete an entity

Type parameters#

Name
M

Parameters#

NameType
__namedParametersDeleteEntityProps<M>

Returns#

Promise<void>

was the whole deletion flow successful

Defined in#

models/datasource.ts:183


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#

NameType
__namedParametersFetchCollectionProps<M>

Returns#

Promise<Entity<M>[]>

Function to cancel subscription

Defined in#

models/datasource.ts:87


fetchEntity#

fetchEntity<M>(__namedParameters): Promise<Entity<M>>

Retrieve an entity given a path and a schema

Type parameters#

Name
M

Parameters#

NameType
__namedParametersFetchEntityProps<M>

Returns#

Promise<Entity<M>>

Defined in#

models/datasource.ts:136


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#

NameType
__namedParametersListenCollectionProps<M>

Returns#

fn

Function to cancel subscription

▸ (): void

Returns#

void

Defined in#

models/datasource.ts:115


listenEntity#

Optional listenEntity<M>(__namedParameters): () => void

Get realtime updates on one entity.

Type parameters#

Name
M

Parameters#

NameType
__namedParametersListenEntityProps<M>

Returns#

fn

Function to cancel subscription

▸ (): void

Returns#

void

Defined in#

models/datasource.ts:152


saveEntity#

saveEntity<M>(__namedParameters): Promise<Entity<M>>

Save entity to the specified path

Type parameters#

Name
M

Parameters#

NameType
__namedParametersSaveEntityProps<M>

Returns#

Promise<Entity<M>>

Defined in#

models/datasource.ts:167