Relationship field validator, raising a validation error when relationship doesn't have at least one object.
Like the isRequired: true
on other fields.
- Add
validateInput: relationRequiredValidateInput
in the hooks of the relationship field
See testSchema/relationshipRequired/index.ts.
On a 1-to-1 or 1-to-many relationship:
- Delete children when parent is deleted
- Do not delete children when they are removed from parent relation
- Use
beforeOperationDeleteOne({ ref: "<child ref>" })
for one-to-one relationships andbeforeOperationDeleteMany({ ref: "<child ref>" })
for one-to-many relationships - The ref value must be the same as the ref config of the relationship field
- Add it as a before operation hook to relationship fields you want to cascade delete
See testSchema/cascadeDelete/oneToOne.ts and testSchema/cascadeDelete/oneToMany.ts.
- Add History schema to your lists
- Add the
afterOperationSaveHistory
hook to any object you want to historize