node-orm2 icon indicating copy to clipboard operation
node-orm2 copied to clipboard

Can't get DATETIME milliseconds?

Open kevin-lxh opened this issue 9 years ago • 2 comments

I defined a datetime field

modifiedDate: {type: 'date', time: true, required: true},

save an item

item.modifiedDate = new Date();
item.save(...);

find the item

Item.get(..., function(err, item) {
    console.log(item.modifiedDate.getMilliseconds()); // will print '0'
});

kevin-lxh avatar Jan 19 '16 05:01 kevin-lxh

I have altered the column to TIMESTAMP type in MySQL level, and it can return milliseconds now. How to define a TIMESTAMP field program programmatically ?

kevin-lxh avatar Jan 19 '16 06:01 kevin-lxh

You will likely need to add a custom type.

dxg avatar Jan 19 '16 23:01 dxg