dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 376 forks source link

Can't get DATETIME milliseconds? #696

Open kevin-lxh opened 8 years ago

kevin-lxh commented 8 years ago

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 commented 8 years ago

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 ?

dxg commented 8 years ago

You will likely need to add a custom type.