Reputation:
db.collection('users', function(err, users)
{
if (!err)
{
users.update({company:cursor[i].name}, {$set:{active:false}}, function() {});
}
});
cursor[i].name
has a string value and it displays fine when I console.log()
it.
The document is not being updated. I am using a remote database in MongoHQ and running a Node.js server with the native mongodb driver. If I run the query on the shell while connected to the same database it works fine.
EDIT: I used an int instead of false
and it worked fine. Can I insert booleans into mongodb? If so, how?
Upvotes: 0
Views: 677
Reputation: 4440
Tested it with 1.2.9 of the driver and it works fine.
exports.shouldUpdateCorrectlyWithBoolean = function (test) {
var db = new Db(MONGODB, new Server("127.0.0.1", 27017,
{auto_reconnect: false, poolSize: 1}), {w: 1, native_parser: false});
db.open(function (err, db) {
db.collection('update_with_boolean').insert({company: 'a'}, function(err, result) {
test.equal(null, err);
db.collection('update_with_boolean').update({company: 'a'}, {$set: {active:false}}, function(err, result) {
test.equal(null, err);
test.equal(1, result);
db.collection('update_with_boolean').findOne(function(err, item) {
test.equal(null, err);
test.equal(false, item.active);
db.close();
test.done();
});
});
})
});
}
Upvotes: 1