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<{ [Key: string]: any; }> | ArrayProperty<CMSType[], any>
entityId?string

Returns​

Promise<boolean>

true if there are no other fields besides the given entity

Defined in​

models/datasource.ts:202


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:187


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:92


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:141


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

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​

models/datasource.ts:120


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

Get realtime updates on one entity.

Returns​

void

Function to cancel subscription

Defined in​

models/datasource.ts:157


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:172