function declareSchema<Names, Types, Constraint, DisplayOption, 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.
If you declare your schema using PrimaryKey values that exactly match (case sensitive) the enum values of
collectionenumfieldtype.ts (e.g. using a key with the value "id" for your ID field) you will be opting in to some
additional (and valuable) user functionality. This includes better support in the edit panel, and better user facing
descriptions of your fields.
Type parameters
| Type parameter |
|---|
Names extends string |
Types extends Readonly<FieldTypeDefinition> |
Constraint extends FieldConstraintDefinition |
DisplayOption extends DisplayMultiUserEditDisplayOptionDefinition |
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;