bastel
bastel

Reputation: 51

Mongo DB update with expire

My new entrys of the unlock schema don't get deleted after 60 seconds. I executed this in the Mongodb shell:

db.unlocks.ensureIndex( { "createdAt": 1 }, { expireAfterSeconds: 60 } )

This is my Schema:

var unlocker = new Schema({createdAt: { type: Date},_id: String, code: String,unlock: Boolean});

Here i add my entrys:

unlock.update({_id:''+ip+''},{createdAT: new Date(),code: ''+code+'',unlock: false},  {upsert:true}...

They should expire but they dont.

Upvotes: 0

Views: 177

Answers (1)

Enrique Fueyo
Enrique Fueyo

Reputation: 3488

There's a typo in your code:

unlock.update({_id:''+ip+''},{createdAT: new Date() ...

should be

unlock.update({_id:''+ip+''},{createdAt: new Date() ...

Upvotes: 1

Related Questions