Watch keynotes and sessions from MongoDB.live, our virtual developer conference.

Node.js callback with MongoDB

I am having problems with this code

const db = mongoskin.db('mongodb://@localhost:27017/test')
const id = mongoskin.helper.toObjectID

Node.js POST method

app.post('/collections/:collectionName', (req, res, next) => {
    pino(req,res);
    req.log.info('pino output');
    req.collection.insert(req.body, {}, (e, results) => {
      if (e) return next(e)
      res.send(results.ops)
    })
})

I was looking at insert documentation but I am struggling to understand .ops.
Whee does it come from?

ops is the insertWriteOpResult object’s property. The results in the code res.send(results.ops) refers to insertWriteOpResult.