Created
July 22, 2017 16:19
-
-
Save WillieYang/500ec10b51fc13e59bfcc5e95e0c22f5 to your computer and use it in GitHub Desktop.
what is the method: mongoose.model();
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Require the Mongoose | |
| var mongoose = require('mongoose'); | |
| // Schema for user | |
| var UserSchema = new mongoose.Schema({ | |
| username: {type: String, required: true}, | |
| email: {type: String, unique: true, required: true}, | |
| password: {type: String, required: true}, | |
| }); | |
| // Compiling the Schema into Model | |
| // First parameter is the name of model, | |
| // and the second parameter is the name of schema. | |
| mongoose.model('User', UserSchema); | |
| // as for the mongoose.model above, it can be used when interacting with mongoDB. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment