The Result Object OPS not Showing in GraphQL with nodejs

Hey Man it’s because of Mongo 4.x update where we no longer have ops instead of that we can do something like this after insert.

const result = await db.collection('Users').insertOne(newUser);
      const someId = result.insertedId;

InsertId and acknowledgement are the only response we get from the db.

you have to run another db query here

const actualResult = await db
        .collection('Users')
        .findOne({ _id: someId });

and if you do console log you will get the inserted document :slight_smile:

Happy Coding

1 Like