sails.js - waterline createdAt affecting sort order -


the symptoms see after adding object viewing list ordered createdat: 'desc', new object @ end of list should @ start of list. noticed date shown e.g. "thu mar 06 2014 10:52:56 gmt+0000 (gmt)" whereas other objects have date "2014-03-06t10:52:56.875z".

if change line in dql.js:

  if(self.autocreatedat) values.createdat = new date(); 

to

  var today = new date();   if(self.autocreatedat) values.createdat = today.toisostring(); 

then sort order comes out correctly.

after restart server, values ok, presumably because data read in disk , converted somewhere.

am misunderstanding in how works , how add objects via waterline?

i had similar issue. if served date field date-string.

i solved adding following methods model: convert date-string date-object before saving it.

... beforecreate: function(values, cb) {     if(values.createdat && typeof value.createdat === 'string'){         values.createdat = new date(date.parse(values.createdat));     }     return cb(); }, beforeupdate: function(values, cb){     if(values.createdat && typeof value.createdat === 'string'){         values.createdat = new date(date.parse(values.createdat));     }     return cb(); } ... 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -