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
Parameter | Type |
---|---|
__namedParameters | object |
__namedParameters.fields | Fields |
__namedParameters.primaryKey | PrimaryKey [] |
Returns
object
array
array: object[];
example
example: Fields = fields;
fromItems()
fromItems: (items) => Map<string, ItemType<Fields>>;
Parameters
Parameter | Type |
---|---|
items | ItemType <Fields >[] |
Returns
Map
<string
, ItemType
<Fields
>>
fromItemsSparse()
fromItemsSparse: (items) => Map<string, PartialItemType<Fields, PrimaryKey>>;
Parameters
Parameter | Type |
---|---|
items | PartialItemType <Fields , PrimaryKey >[] |
Returns
Map
<string
, PartialItemType
<Fields
, PrimaryKey
>>
primaryKey
primaryKey: FormattedPrimaryKey<Fields, PrimaryKey> = primaryKeyObj;