A class that represents a MongoDB collection configuration. Provides full support for schema validation, access control through permissions, and custom triggers for various database operations.
Deprecated
Use defineCollection
instead.
Example
typescript
const userSchema = new Schema({
name: String,
email: String,
age: Number
});
const collection = new CollectionDefinition({
database: 'myapp',
collection: 'users',
schema: userSchema,
permissions: [
new Permission({
type: 'user_access',
read: true,
write: true
})
],
triggers: [
new DatabaseTrigger('insert-one', (data) => {
console.log('New user created:', data);
})
]
});
Properties
Property | Modifier | Type | Description |
---|---|---|---|
collection | readonly | string | The name of the collection |
database | readonly | string | The name of the database |
permissions | readonly | Permission [] | List of permissions for the collection |
schema | readonly | Schema | Mongoose schema definition |
triggers? | readonly | DatabaseTrigger [] | Optional database triggers |