[MONGO CP] updatedAt returns nil

5 views
Skip to first unread message

Observer

unread,
Feb 12, 2016, 12:19:50 AM2/12/16
to Coronium IO
Hi develephant, Im just having issues getting the 'updatedAt' result from mongo cp. I can get other objects but not the last time it was updated. Im using getObject function instead of updateObject function to retrieve it. Since my goal is to get the last time it was modified not by me but by other users. Any idea?

develephant

unread,
Feb 12, 2016, 4:32:02 PM2/12/16
to Coronium IO
Hi,

One approach is to just add an "updated" key and push a timestamp using os.time() at it. If you want the times to be "synced" then you would need to do the update via cloud code. If you update and call the os.time() from the client, the results will differ by timezone.

Surprisingly, getting the Mongo "updatedAt" value is not so trivial in Lua, as it resides in an additional BSON object as part of the Mongo document. I'll take a look at the module code and see if I can pull it out.

Hope that helps.

Cheers.

develephant

unread,
Feb 12, 2016, 5:55:10 PM2/12/16
to Coronium IO
Hi,

On further research, I found that there is no "updatedAt" available through the Lua Mongo driver, only createdAt (which is a timestamp like os.time() produces). So you will need to handle the "update" timestamp on the record directly.

Cheers. 
Reply all
Reply to author
Forward
0 new messages