-
Notifications
You must be signed in to change notification settings - Fork 0
Definition of Model
Markus Gilg edited this page Oct 21, 2018
·
7 revisions
A collection can always be only one class or an inherited class. To do this, the class must be provided with an @collection decorator.
@collection({
allow: 'CUD'
})
export class User {
@validation({type:BaseTypes.mongoDbObjectId.default(null)})
_id: string;
@validation({type:BaseTypes.stringDefaultLength})
firstName: string;
@validation({type:BaseTypes.stringDefaultLength})
lastName: string;
@validation({type:BaseTypes.email})
email: string;
accounts: BankAccount[];
}
The least the @collection decorator needs is permissions. This is done via the allow property. This is a string and indicates whether an object can be created, updated or deleted. The following combinations are possible:
- CUD => All 3 operations are possible
- XUD => No new objects can be created but existing objects can be update/deleted.
- XXD => Only objects can be deleted
- XXX => The Collection is read-only
- CUX => Only objects can be created/updated.
- CXX => Only objects can be created