How to use the Model function from mongoose

Find comprehensive JavaScript mongoose.Model code examples handpicked from public code repositorys.

82
83
84
85
86
87
88
89
90
91
* Does it support custom model static method? Yes!
* mongoomise.promisifyAll should be invoked `after` all models are `loaded`

## mongoose basics

> * your models extends from mongoose.Model
> * schemas are stored on global mongoose but models may not
> * mongoose.models.ModelName equals to mongoose.model('ModelName')
> * ModelName.schema equals to mongoose.modelSchemas.ModelName
> * static methods should be extended on mongoose.Model with a dynamic context
fork icon7
star icon48
watch icon6

+ 23 other calls in file

52
53
54
55
56
57
58
59
60
61
        throw new Error("Invalid Password")
    }
    return User;
}


const User = mongoose.Model({'User', UserSchema});


module.exports = User
fork icon0
star icon0
watch icon0