Created
May 9, 2014 11:17
-
-
Save nazrdogan/0de55d4aaf81ceed8547 to your computer and use it in GitHub Desktop.
MongoDB insert Document
This file contains 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 mongoose = require('mongoose'); | |
mongoose.connect('mongodb://localhost/bookmarks'); | |
var db=mongoose.connection; | |
db.on('error', console.error.bind(console, 'connection error:')); | |
db.once('open', function callback () { | |
console.log('Running'); | |
var Users = mongoose.model('users', { name: String, lastname: String, yas: Number, yer: String }); | |
var userYeni = new Users({ | |
name: 'Nazır1', | |
lastname: 'Doğan', | |
yas: 25, | |
yer: 'İstanbul', | |
}); | |
userYeni.save(function (err, ok) { | |
if (err) { | |
console.log('Kayıt Eklenemedi'); | |
} | |
if (ok) { | |
console.log('Kayıt Eklendi'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment