Skip to content

Instantly share code, notes, and snippets.

@DTrejo
Created August 2, 2010 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DTrejo/505159 to your computer and use it in GitHub Desktop.
Save DTrejo/505159 to your computer and use it in GitHub Desktop.
var item = { "hdbarcode": hdbarcode, "description": description };
// 2nd argument is callback
getDescription(item.hdbarcode, function(upcDescrip){
db.save(null, item, function (err, meta) {
// This does not change item on line 1. Why?
item.key = meta.key;
sys.puts('saved ' + JSON.stringify(item) + ' as '+ meta.key);
});
});
// tell client
res.simpleJSON(200, { "key": item.key, "message": "Success!" });
// key is undefined, because item.key was never set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment