Search code examples
node.jsmongodbmonk

Stop Monk from adding _id to docs


Is there a way to stop monk from generating and adding _id to docs ? Or is there a driver for MongoDb in Node.js that doesn't auto add _id ?


Solution

  • _id is needed in every doc. If you don't want auto generated _id then you have to add a custom one. But every doc should have _id in mongo.

    You can add your own _id and insert it when inserting doc. Just make sure _id is unique across all docs in a collection. It should be what primary key is in RDBMS.