Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nodejs - mongodb - how to remove a record

This is the data

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

This is the code I used to use to remove a record

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

I want to delete the session which has been expired. Problem is, the code doesn't work, maybe there is something to do with numberLong ?

like image 643
angry kiwi Avatar asked Jun 15 '11 15:06

angry kiwi


Video Answer


1 Answers

It looks like you misspelled "session" (as "seesion").

like image 136
maerics Avatar answered Oct 26 '22 11:10

maerics