0
attributes : {
   username   : { type: "string",required:true,unique:true },
   password   : { type : "string",required:true},
   email      : { type : "string",required:true,unique:true},
   expireAt   : { type:'date','defaultsTo':Date.now(),'expires':'4m' },
}

the data store good, but ignore the field expireAt because expires is not one attribute native of waterline and then the document not expire never, ¿ is possible get one behave like the mongoose schema ?

http://docs.mongodb.org/manual/tutorial/expire-data/

Maxtermax
  • 145
  • 2
  • 12

1 Answers1

0

For get the behave of expires i have to do this :

  attributes : {
    username   : { type: "string",required:true,unique:true },
    password   : { type : "string",required:true},
   email      : { type : "string",required:true,unique:true},
   expireAt   : { type : "date",'defaultsTo':new Date()}
  }

remove expires of the schema

        User.native(function (err, collection) {
           if(err) return console.log(err,"err")
           collection.createIndex({  "expireAt" : 1}, {expireAfterSeconds: 30 },(error,data)=> error ? console.log(error,"error") : console.log(data,"data") );         
        User
            .create(info)
            .exec( (err,user) => err ? res.badRequest(err) : res.ok(user) )
    })

Access to native driver of mongodb and follow this tutorial

Maxtermax
  • 145
  • 2
  • 12