mongoose-model-create
v1.0.2
Published
Short-hand for creating `mongoose` model using `Typescript`.
Downloads
3
Readme
Mongoose model create
Short-hand for creating mongoose model using Typescript.
// Define attributes.
interface TestAttrs {
name: string
}
// Create model.
const Test = createModel<TestAttrs>('Test', {
name: {
type: String,
required: true
}
});
// Create instance of the model with build method.
const test = Test.build({name: 'new test'})
await test.save()