npm.io
1.0.2 • Published 4 years ago

mongoose-model-create

Licence
ISC
Version
1.0.2
Deps
1
Size
2 kB
Vulns
0
Weekly
0

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

Keywords