Skip to content

Instantly share code, notes, and snippets.

@ps2
Created October 9, 2016 23:36
Show Gist options
  • Select an option

  • Save ps2/eac5e24a66d7be23324c6dbb082011fc to your computer and use it in GitHub Desktop.

Select an option

Save ps2/eac5e24a66d7be23324c6dbb082011fc to your computer and use it in GitHub Desktop.

How can this code:

    api( ).update(query, obj, {upsert: true, new: true}, function complete (err, r1) {
      if (!err) {
        console.log("r1 = " + r1)
        console.log("typeof(r1) = " + typeof(r1))
        console.log("r1.upserted = " + r1.upserted)
        console.log("Object.keys(r1) = " + Object.keys(r1))

Produce this output?

6:35:01 PM web.1 |  r1 = {"ok":1,"nModified":0,"n":1,"upserted":[{"index":0,"_id":"57fad425b28c52467dacf0a0"}],"opTime":{"ts":"6339612680856272897","t":0},"electionId":"7fffffff0000000000000000"}
6:35:01 PM web.1 |  typeof(r1) = object
6:35:01 PM web.1 |  r1.upserted = undefined
6:35:01 PM web.1 |  Object.keys(r1) = result,connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment