Files
firecms/website/docs/api/interfaces/entityschema.md
2021-06-06 13:36:47 +02:00

4.6 KiB

id, title, sidebar_label, sidebar_position, custom_edit_url
id title sidebar_label sidebar_position custom_edit_url
entityschema Interface: EntitySchema<Key, T> EntitySchema 0 null

Specification for defining an entity

Type parameters

Name Type
Key Key: string = string
T T: any = any

Properties

customId

Optional customId: boolean | EnumValues

If this property is not set Firestore will create a random ID. You can set the value to true to allow the users to choose the ID. You can also pass a set of values (as an EnumValues object) to allow them to pick from only those

Defined in

models/models.ts:210


defaultValues

Optional defaultValues: Partial<EntityValues<EntitySchema<Key, T>, Key>>

When creating a new entity, set some values as already initialized

Defined in

models/models.ts:220


description

Optional description: string

Description of this entity

Defined in

models/models.ts:202


name

name: string

Singular name of the entity as displayed in an Add button . E.g. Product

Defined in

models/models.ts:197


properties

properties: PropertiesOrBuilder<EntitySchema<Key, T>, Key, T>

Set of properties that compose an entity

Defined in

models/models.ts:215

Methods

onDelete

Optional onDelete(entityDeleteProps): void

Hook called after the entity is deleted in Firestore.

Parameters

Name Type
entityDeleteProps EntityDeleteProps<EntitySchema<Key, T>, Key>

Returns

void

Defined in

models/models.ts:259


onPreDelete

Optional onPreDelete(entityDeleteProps): void

Hook called after the entity is deleted in Firestore. If you throw an error in this method the process stops, and an error snackbar gets displayed.

Parameters

Name Type
entityDeleteProps EntityDeleteProps<EntitySchema<Key, T>, Key>

Returns

void

Defined in

models/models.ts:252


onPreSave

Optional onPreSave(entitySaveProps): EntityValues<EntitySchema<Key, T>, Key> | Promise<EntityValues<EntitySchema<Key, T>, Key>>

Hook called before saving, you need to return the values that will get saved. If you throw an error in this method the process stops, and an error snackbar gets displayed.

Parameters

Name Type
entitySaveProps EntitySaveProps<EntitySchema<Key, T>, Key>

Returns

EntityValues<EntitySchema<Key, T>, Key> | Promise<EntityValues<EntitySchema<Key, T>, Key>>

Defined in

models/models.ts:242


onSaveFailure

Optional onSaveFailure(entitySaveProps): void | Promise<void>

Hook called when saving fails

Parameters

Name Type
entitySaveProps EntitySaveProps<EntitySchema<Key, T>, Key>

Returns

void | Promise<void>

Defined in

models/models.ts:233


onSaveSuccess

Optional onSaveSuccess(entitySaveProps): void | Promise<void>

Hook called when save is successful

Parameters

Name Type
entitySaveProps EntitySaveProps<EntitySchema<Key, T>, Key>

Returns

void | Promise<void>

Defined in

models/models.ts:226