Skip to main content
Version: 3.0.0-beta

Interface: DataSource

Component in charge of communicating with the data source. Usually you won't need to implement this interface, but a DataSourceDelegate instead.

Properties​

initTextSearch()?​

optional initTextSearch: (props) => Promise<boolean>

Called when the user clicks on the search bar in a collection view. Useful for initializing a text search index.

Parameters​

• props

• props.collection: EntityCollection<any, any>

• props.context: FireCMSContext

• props.parentCollectionIds?: string[]

• props.path: string

Returns​

Promise<boolean>

Defined in​

packages/firecms_core/src/types/datasource.ts:229

Methods​

checkUniqueField()​

checkUniqueField(path, name, value, entityId?, collection?): Promise<boolean>

Check if the given property is unique in the given collection

Parameters​

• path: string

Collection path

• name: string

of the property

• value: any

• entityId?: string

• collection?: EntityCollection<any, any>

Returns​

Promise<boolean>

true if there are no other fields besides the given entity

Defined in​

packages/firecms_core/src/types/datasource.ts:200


countEntities()?​

optional countEntities<M>(props): Promise<number>

Count the number of entities in a collection

Type Parameters​

• M extends Record<string, any> = any

Parameters​

• props: FetchCollectionProps<M>

Returns​

Promise<number>

Defined in​

packages/firecms_core/src/types/datasource.ts:216


deleteEntity()​

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

Delete an entity

Type Parameters​

• M extends Record<string, any> = any

Parameters​

• entity: DeleteEntityProps<M>

Returns​

Promise<void>

was the whole deletion flow successful

Defined in​

packages/firecms_core/src/types/datasource.ts:184


fetchCollection()​

fetchCollection<M>(__namedParameters): Promise<Entity<M>[]>

Fetch data from a collection

Type Parameters​

• M extends Record<string, any> = any

Parameters​

• __namedParameters: FetchCollectionProps<M>

Returns​

Promise<Entity<M>[]>

Function to cancel subscription

See​

useCollectionFetch if you need this functionality implemented as a hook

Defined in​

packages/firecms_core/src/types/datasource.ts:90


fetchEntity()​

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

Retrieve an entity given a path and a collection

Type Parameters​

• M extends Record<string, any> = any

Parameters​

• __namedParameters: FetchEntityProps<M>

Returns​

Promise<Entity<M>>

Defined in​

packages/firecms_core/src/types/datasource.ts:139


generateEntityId()​

generateEntityId(path, collection): string

Generate an id for a new entity

Parameters​

• path: string

• collection: EntityCollection<any, any>

Returns​

string

Defined in​

packages/firecms_core/src/types/datasource.ts:211


isFilterCombinationValid()?​

optional isFilterCombinationValid(props): boolean

Check if the given filter combination is valid

Parameters​

• props: FilterCombinationValidProps

Returns​

boolean

Defined in​

packages/firecms_core/src/types/datasource.ts:222


listenCollection()?​

optional listenCollection<M>(__namedParameters): () => 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.

Type Parameters​

• M extends Record<string, any> = any

Parameters​

• __namedParameters: ListenCollectionProps<M>

Returns​

Function

Function to cancel subscription

Returns​

void

See​

useCollectionFetch if you need this functionality implemented as a hook

Defined in​

packages/firecms_core/src/types/datasource.ts:118


listenEntity()?​

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

Get realtime updates on one entity.

Type Parameters​

• M extends Record<string, any> = any

Parameters​

• __namedParameters: ListenEntityProps<M>

Returns​

Function

Function to cancel subscription

Returns​

void

Defined in​

packages/firecms_core/src/types/datasource.ts:155


saveEntity()​

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

Save entity to the specified path

Type Parameters​

• M extends Record<string, any> = any

Parameters​

• __namedParameters: SaveEntityProps<M>

Returns​

Promise<Entity<M>>

Defined in​

packages/firecms_core/src/types/datasource.ts:170

Sign up to our newsletter to get the latest news and updates. No spam!