2011-06-15 104 views
11

这是数据的NodeJS - MongoDB的 - 如何删除记录

{ 
    "username": "runrun", 
    "channel": "all", 
    "expire": NumberLong("1308183908743"), 
    "_id": ObjectId("4df93f54e07324af47000001") 
} 

这是我以前用的删除记录

db.collection('seesion',function(err, collection){ 
    collection.remove({ 
     "expire": {"$lte": Date.now()} 
    },function(err, removed){ 
     console.log(removed); 
    }); 
}); 

我想删除它具有会话代码已过期。问题是,代码不起作用,或许有关于numberLong的事情?

回答

18

它看起来像拼写错误的“会话”(如“seesion”)。

+0

耶稣我收集拼写错误的名称,这就是为什么;)。我的代码工作,你只是把它放在db.open(函数(){}) – 2011-06-15 17:10:52

+0

对,我得到的代码毕竟,但后来意识到错字。发生在我们最好的=) – maerics 2011-06-15 17:15:30

+0

@angry_kiwi你是否在为此目的使用猫鼬? – 2016-10-17 01:48:38