defineCollection(
options
):CollectionDefinition
To have define any collection in your database you haveto use below method in your db.[js|ts]
file and export an array of CollectionDefinition instances.
Example
typescript
import { defineCollection } from '@modular-rest/server';
export default [
defineCollection({
database: 'users',
collection: 'info',
// schema: Schema,
// permissions: Permission[]
// trigger: DatabaseTrigger[]
})
]
Parameters
Parameter | Type | Description |
---|---|---|
options | { collection : string ; database : string ; permissions : Permission []; schema : Schema ; triggers : DatabaseTrigger []; } | The options for the collection |
options.collection | string | The name of the collection to be configured |
options.database | string | The name of the database where the collection resides |
options.permissions | Permission [] | List of permissions controlling access to the collection |
options.schema | Schema | Mongoose schema definition for the collection See https://mongoosejs.com/docs/5.x/docs/guide.html |
options.triggers ? | DatabaseTrigger [] | Optional database triggers for custom operations |
Returns
A new instance of CollectionDefinition