Collectionclass

new Collection<N, I, T>(name: N, id: Schema<I>, data: Schemas<T> | DataSchema<T>)
ParamType
nameN
Collection name used as the table/collection key. required
idSchema<I>
Schema for the identifier type. required
dataSchemas<T>
DataSchema<T>
Data schema, or the Schemas props used to construct one. required
Return
Collection<N, I, T>
Declarative definition of a database collection/table.
PropertyType
.nameN
Collection name (used as the table/collection key). required readonly
.idSchema<I>
Schema for the identifier type. required readonly
.itemDataSchema<Item<I, T>>
Schema for a complete item (id + data). required readonly

Declarative definition of a database collection/table.

  • Pairs a collection name with an identifier schema and a data schema, so providers can validate and address items.
  • Extends DataSchema<T>, so the collection itself validates an item's data, while .item validates the complete id + data item.

Examples

const users = new Collection("users", ID, { name: STRING, age: NUMBER });
 users.validate({ name: "Dave", age: 40 }); // Validates item data.