I need to attach timestamp to messages which will be saved in MongoDB. How can I do that using server side scripting? How should I get server date?
Here’s my attempt:
mongodb._table.tabletest.post.pre_process
var lodash = require("lodash.min.js");
if (event.request.payload.resource) {
var resource = event.request.payload.resource;
resource.timestamp = Date.now();
// set this flag if you change the response content
event.request.content_changed = true;
}
It may be useful for someone.
1 Like
Hey @hedisam thanks so much for replying with your solution! This will be very helpful for our community and I am glad to see that you figured it out.
Happy coding!
@AlexBowen
1 Like