mongo query by object id node js
//declare ObjectId from mongodb module
const ObjectId = require('mongodb').ObjectId;
//transform your param into an ObjectId
var id = req.params.id;
var good_id = new ObjectId(id);
//you can now query
Model.find({_id: good_id})
Also in JavaScript:
- check if js object is empty
- react not recognizing lorem
- js clear text in input
- pi in js
- get the last element of array javascript
- vuex-module-decorators nuxt axios
- nodejs map
- javascript subtract years from date
- js is empty object
- react router 404 redirect
- generate number using math random in javascript
- send json body http get flutter
- javascript go to url
- how store array in another array js
- jquery ajax get
- react useref in useeffect
- get the difference between two dates js
- js vue array change position
- random image and link js
- animated list in js
- redux action to hit api and assign data in stateless component
- how to add links in react js
- call method in javascript
- node load file