I get the error "TypeError: I can not read the property" _id "from undefined" on a simple mail request to save the document in a collection called books . My payload is as follows:
{ "name": "practical view", "author": "DN", "location": "room 50" }
And I just do db.books.save() in my route in express. Since I do not pass id, this should work perfectly, but not in this case.
Below is the full error dump that I get on the node server:
C:\NodeProjects\ExpressTutorial\Library\node_modules\mongojs\node_modules\mongodb\lib\mongodb\mongo_client.js:411 throw err ^ TypeError: Cannot read property '_id' of undefined at Collection.save (C:\NodeProjects\ExpressTutorial\Library\node_modules\mongojs\node_modules\mongodb\lib\mongodb\collection.js:393:15) at C:\NodeProjects\ExpressTutorial\Library\node_modules\mongojs\index.js:203:65 at apply (C:\NodeProjects\ExpressTutorial\Library\node_modules\mongojs\node_modules\thunky\index.js:16:28) at C:\NodeProjects\ExpressTutorial\Library\node_modules\mongojs\node_modules\thunky\index.js:20:25 at Db.collection (C:\NodeProjects\ExpressTutorial\Library\node_modules\mongojs\node_modules\mongodb\lib\mongodb\db.js:488:44) at C:\NodeProjects\ExpressTutorial\Library\node_modules\mongojs\index.js:268:7 at apply (C:\NodeProjects\ExpressTutorial\Library\node_modules\mongojs\node_modules\thunky\index.js:16:28) at C:\NodeProjects\ExpressTutorial\Library\node_modules\mongojs\node_modules\thunky\index.js:20:25 at C:\NodeProjects\ExpressTutorial\Library\node_modules\mongojs\index.js:300:4 at C:\NodeProjects\ExpressTutorial\Library\node_modules\mongojs\node_modules\mongodb\lib\mongodb\mongo_client.js:408:11 31 Aug 00:14:30 - [nodemon] app crashed - waiting for file changes before starting...
source share