Mongoose Schema

DryerJS generates mongoose schema from class definition.

Customization

You can override the default behavior by using schemaOptions option on @Definition decorator.

@Definition({ schemaOptions: { timestamps: true } })
class Tag {}

You can also use onSchema option on @DryerModule.register.

// app.module.ts
@DryerModule.register({
  definitions: [Tag],
  onSchema: (schema, definition) => {
    schema.set('timestamps', true);
  },
});

Index decorator

import { Index, Definition } from 'dryerjs';
 
@Index({ name: 1 }, { unique: true })
@Definition()
class Tag {}
💡

Index is imported from 'dryerjs'.