declareSchema

function declareSchema<Names, Types, Constraint, Fields, PrimaryKey>(__namedParameters): object

Specifies all the fields that this itegration will be sending to the data-sync service.
Give you well typed methods to convert from YourType[] to {[PrimaryKey:string]: YourType}
which is what most of the data sync service calls expect.

There is fromItems which does the above will full type information, and fromItems sparse
which allows all the fields not part of the primaryKey to be undefined. The former should
be used with initial imports, and the latter can be used for updates.

Type parameters

Type parameter
Names extends string
Types extends Readonly<FieldTypeDefinition>
Constraint extends FieldConstraintDefinition
Fields extends { [Name in string]: Object }
PrimaryKey extends string | number | symbol

Parameters

ParameterType
__namedParametersobject
__namedParameters.fieldsFields
__namedParameters.primaryKeyPrimaryKey[]

Returns

object

array

array: object[];

example

example: Fields = fields;

fromItems()

fromItems: (items) => Map<string, ItemType<Fields>>;

Parameters

ParameterType
itemsItemType<Fields>[]

Returns

Map<string, ItemType<Fields>>

fromItemsSparse()

fromItemsSparse: (items) => Map<string, PartialItemType<Fields, PrimaryKey>>;

Parameters

ParameterType
itemsPartialItemType<Fields, PrimaryKey>[]

Returns

Map<string, PartialItemType<Fields, PrimaryKey>>

primaryKey

primaryKey: FormattedPrimaryKey<Fields, PrimaryKey> = primaryKeyObj;