Created
June 27, 2019 17:49
-
-
Save barmgeat/3dbf21bafaf9f30fd7f26e6d5e4979bf to your computer and use it in GitHub Desktop.
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
var userSchema = mongoose.Schema({ | |
"id": Number, | |
"username": String, | |
"paswod": String, | |
"name": String, | |
"last_name": String | |
}); | |
var user = mongoose.model('users', userSchema); | |
// to fetch all users | |
user.find(function (err, user) { | |
if (err) return console.error(err); | |
console.log(user); | |
}); | |
// to get specific user | |
user.find({ name: /^mmustafa/ }, function (err, user) { | |
if (err) return console.error(err); | |
console.log(user); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment