@medic/cht-datasource
    Preparing search index...

    Interface Datasource

    Operations for working with places.

    interface Datasource {
        create: (input: PlaceInput) => Promise<Place.v1.Place>;
        getByType: (placeType: string) => AsyncGenerator<Place.v1.Place, null>;
        getByUuid: (uuid: string) => Promise<Nullable<Place.v1.Place>>;
        getByUuidWithLineage: (uuid: string) => Promise<Nullable<PlaceWithLineage>>;
        getPageByType: (
            placeType: string,
            cursor?: Nullable<string>,
            limit?: number | `${number}`,
        ) => Promise<Page<Place.v1.Place>>;
        update: <T extends Place.v1.Place | PlaceWithLineage>(
            updated: UpdatePlaceInput<T>,
        ) => Promise<T>;
    }
    Index

    Properties

    create: (input: PlaceInput) => Promise<Place.v1.Place>

    Creates a new place record.

    Type Declaration

    InvalidArgumentError if type is not provided or is not a supported place contact type

    InvalidArgumentError if name is not provided

    InvalidArgumentError if parent is not provided for types requiring a parent or is not the identifier of a valid contact. The parent contact's type must be one of the supported parent contact types for the new place.

    InvalidArgumentError if the provided reported_date is not in a valid format. Valid formats are 'YYYY-MM-DDTHH:mm:ssZ', 'YYYY-MM-DDTHH:mm:ss.SSSZ', or .

    InvalidArgumentError if the provided contact is not the identifier of a valid person contact

    getByType: (placeType: string) => AsyncGenerator<Place.v1.Place, null>

    Returns a generator for fetching all places with the given type.

    Type Declaration

      • (placeType: string): AsyncGenerator<Place.v1.Place, null>
      • Parameters

        • placeType: string

          the type of place to return

        Returns AsyncGenerator<Place.v1.Place, null>

        a generator for fetching all places with the given type

    InvalidArgumentError if no type if provided or if the type is not a supported place contact type

    getByUuid: (uuid: string) => Promise<Nullable<Place.v1.Place>>

    Returns a place by its UUID.

    Type Declaration

    InvalidArgumentError if no UUID is provided

    getByUuidWithLineage: (uuid: string) => Promise<Nullable<PlaceWithLineage>>

    Returns a place by its UUID along with the place's parent lineage.

    Type Declaration

    InvalidArgumentError if no UUID is provided

    getPageByType: (
        placeType: string,
        cursor?: Nullable<string>,
        limit?: number | `${number}`,
    ) => Promise<Page<Place.v1.Place>>

    Returns an array of places for the provided page specifications.

    Type Declaration

      • (
            placeType: string,
            cursor?: Nullable<string>,
            limit?: number | `${number}`,
        ): Promise<Page<Place.v1.Place>>
      • Parameters

        • placeType: string

          the type of place to return

        • Optionalcursor: Nullable<string>

          the token identifying which page to retrieve. A null value indicates the first page should be returned. Subsequent pages can be retrieved by providing the cursor returned with the previous page.

        • Optionallimit: number | `${number}`

          the maximum number of place to return. Default is 100.

        Returns Promise<Page<Place.v1.Place>>

        a page of places for the provided specifications

    InvalidArgumentError if no type is provided or if the type is not a supported place contact type

    InvalidArgumentError if the provided limit is <= 0

    InvalidArgumentError if the provided cursor is not a valid page token or null

    getByType which provides the same data, but without having to manually account for paging

    update: <T extends Place.v1.Place | PlaceWithLineage>(
        updated: UpdatePlaceInput<T>,
    ) => Promise<T>

    Updates an existing place to have the provided data.

    Type Declaration

      • <T extends Place.v1.Place | PlaceWithLineage>(
            updated: UpdatePlaceInput<T>,
        ): Promise<T>
      • Type Parameters

        Parameters

        • updated: UpdatePlaceInput<T>

          the updated place data. The complete data for the place must be provided. Existing fields not included in the updated data will be removed from the place. If the provided parent/contact lineage is hydrated (e.g. for a v1.PlaceWithLineage), the lineage will be properly dehydrated before being stored.

        Returns Promise<T>

        the updated place with the new _rev value

    InvalidArgumentError if _id is not provided

    ResourceNotFoundError if _id does not identify an existing place contact

    InvalidArgumentError if _rev is not provided or does not match the place's current _rev value

    InvalidArgumentError if name is not provided

    InvalidArgumentError if the provided contact is not the identifier of a valid person contact

    InvalidArgumentError if any of the following read-only properties are changed: reported_date, parent, type, contact_type