1.0.2 • Published 2 years ago

mongoose-model-create v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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()