Note that there are some explanatory texts on larger screens.

plurals
  1. POMongodb (using mongoose) expiresAfterSeconds (TTL) doesn't seem to work
    primarykey
    data
    text
    <p>I'm using mongoose for this.</p> <p>My Schema is like this:</p> <pre><code>var UsuarioSchema = new Schema({ email : { type : Email, index : { unique : true}, required : true }, //some other fields, but not required, hopefully, for this sample code test_expira : { type : Date, default : Date.now, index : { expires : 120 }} }); </code></pre> <p>When running on the mongodb shell, this is the information that I believe matters:</p> <pre><code>&gt; db.usuarios.getIndexes() [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "dbnamehere.usuarios", "name" : "_id_" }, { "v" : 1, "key" : { "email" : 1 }, "unique" : true, "ns" : "dbnamehere.usuarios", "name" : "email_1", "background" : true, "safe" : true }, { "v" : 1, "key" : { "test_expira" : 1 }, "ns" : "dbnamehere.usuarios", "name" : "test_expira_1", "expiresAfterSeconds" : 120, "background" : true, "safe" : true } ] &gt; new Date(); ISODate("2013-06-12T17:41:43.263Z") &gt; db.usuarios.findOne({email : 'someemail@gmail.com'}); { /* some fields go in here! */ "email" : "someemail@gmail.com", /* some more fields go in here */ "_id" : ObjectId("51b8b087de01a2ec28000002"), "test_expira" : ISODate("2013-06-12T17:31:51.156Z"), /* some yet more fields go in here */ "__v" : 0 } </code></pre> <p>I haven't tested for how long it goes without getting deleted, but even the docs state only a minute overhead should be what one could expect, but not over 15 minutes for a document that should last only 120 seconds.</p> <p>I'm unsure of how to deal with this. Help will be greatly appreciated :)</p> <p>EDIT: Version of mongodb being used is v2.4.4 Version of mongoose is 3.0.3</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload