Skip to main content

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

Index

Properties

optionalinitTextSearch

initTextSearch?: (props: { collection: EntityCollection<any, any>; context: FireCMSContext; parentCollectionIds?: string[]; path: string }) => Promise<boolean>

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


Type declaration

Methods

checkUniqueField

  • checkUniqueField(path: string, name: string, value: any, entityId?: string): 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
    • optionalentityId: string

    Returns Promise<boolean>

    true if there are no other fields besides the given entity

optionalcountEntities

  • Count the number of entities in a collection


    Type parameters

    • M: Record<string, any> = any

    Parameters

    Returns Promise<number>

deleteEntity

  • Delete an entity


    Type parameters

    • M: Record<string, any> = any

    Parameters

    Returns Promise<void>

    was the whole deletion flow successful

fetchCollection

  • Fetch data from a collection

    @see

    useCollectionFetch if you need this functionality implemented as a hook


    Type parameters

    • M: Record<string, any> = any

    Parameters

    Returns Promise<Entity<M>[]>

    Function to cancel subscription

fetchEntity

  • Retrieve an entity given a path and a collection


    Type parameters

    • M: Record<string, any> = any

    Parameters

    Returns Promise<undefined | Entity<M>>

generateEntityId

  • generateEntityId(path: string): string
  • Generate an id for a new entity


    Parameters

    • path: string

    Returns string

optionalisFilterCombinationValid

optionallistenCollection

  • 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

    • M: Record<string, any> = any

    Parameters

    Returns () => void

    Function to cancel subscription

      • (): void
      • Returns void

optionallistenEntity

  • Get realtime updates on one entity.


    Type parameters

    • M: Record<string, any> = any

    Parameters

    Returns () => void

    Function to cancel subscription

      • (): void
      • Returns void

saveEntity

  • Save entity to the specified path


    Type parameters

    • M: Record<string, any> = any

    Parameters

    Returns Promise<Entity<M>>

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