Skip to content

Instantly share code, notes, and snippets.

@jpwsutton
Created March 18, 2014 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpwsutton/9625808 to your computer and use it in GitHub Desktop.
Save jpwsutton/9625808 to your computer and use it in GitHub Desktop.
Sanitised Owntracks packet for being stored in mongoDB
// The received message is stored in 'msg'
// It will have at least a 'payload' property:
// console.log(msg.payload);
// The 'context' object is available to store state
// between invocations of the function
// context = {};
var date = new Date().toISOString().slice(0, 19).replace('T', ' ');
var user = 'james';
msg.payload = JSON.parse(msg.payload);
msg.payload.user = user;
msg.payload.date = date;
return msg;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment