1.0.0 • Published 3 years ago
mongoose-auto-ts v1.0.0
Installation:
npm i mongoose-auto-ts
Description:
This tiny package infers types from mongoose schema without needing to do that manually.
Usage:
// Schema & model must be imported from this package instead of mongoose.
import { Schema, model } from 'mongoose-auto-ts';
//Options argument has two extra properties: statics AND methods.
const UserSchema = new Schema({
email: {
type: String,
required: true,,
unique: true,
},
password: {
type: String,
required: true,
},
},
{
statics: {
// Static methods should be defined here to be able to get better hints.
},
methods: {
// Instance methods should be defined here to be able to get better hints.
}
});
const User = model('User', UserSchema);
export default User;