Created
May 1, 2012 17:01
-
-
Save aheckmann/2569624 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 mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
mongoose.connect('localhost', 'testing_876'); | |
mongoose.connection.on('error', function () { | |
console.error(arguments); | |
}); | |
var schema = new Schema({ | |
name: String | |
, active : {type:Boolean, default: false } | |
}); | |
var A = mongoose.model('A', schema); | |
mongoose.connection.on('open', function () { | |
var a = new A({ name: '876' }); | |
a.save(function (err, a) { | |
if (err) return console.error(err.stack||err); | |
// confirm the data in the db by skipping mongoose | |
//A.collection.findOne({ _id: a._id }, function (err, doc) { | |
// console.error(doc); | |
//}); | |
A.findOne({ _id: a._id }, ['name','active'], function (err, doc) { | |
if (err) console.error(err); | |
console.error(doc.active); | |
mongoose.connection.close(); | |
}); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment