0
db.collection('users', function(err, users)
{
    if (!err)
    {
        users.update({company:cursor[i].name}, {$set:{active:false}}, function() {});
    }
});

cursor[i].name文字列値があり、それを使用すると正常に表示されますconsole.log()

ドキュメントは更新されていません。MongoHQ でリモート データベースを使用し、ネイティブ mongodb ドライバーで Node.js サーバーを実行しています。同じデータベースに接続しているときにシェルでクエリを実行すると、正常に動作します。

編集:代わりにintを使用しましたが、falseうまくいきました。ブール値をmongodbに挿入できますか? もしそうなら、どのように?

4

1 に答える 1

1

1.2.9 のドライバーでテストしたところ、正常に動作しました。

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();
        });
      });
    })
  });
}
于 2013-01-15T12:25:48.460 に答える