What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-10-21 08:30:19
connecting , creating ,reading from mongo
const MongoClient = require('mongodb').MongoClient; // Connection URL const url = 'mongodb://localhost:27017'; // Database Name const dbName = 'mytestingdb'; const retrieveCustomers = (db, callback)=>{ // Get the customers collection const col... Add solution -
Javascript 2021-10-16 10:42:07
I use time stamp in mongoose sort by date
Article.find({}).sort('-date').exec(function(err, docs) { ... });Article.find({}).sort({date: -1}).exec(function(err, docs) { ... });Article.find({}).sort({date: 'desc'}).exec(function(err, docs) { ... });Article.find({}).sort({date: 'descending'}).exec(f... Add solution -
Other 2021-10-08 04:19:04
mongodb projection example
db.student.find({}, 'roll _id'); // <--- Just multiple fields name space separated // OR db.student.find({}).select('roll _id'); // <--- Just multiple fields name space separated // OR db.student.find({}, {'roll' : 1 , '_id' : 1 ); // <---- Old l... Add solution -
Other 2021-10-05 21:13:02
mongodb select specific fields
db.student.find({}, 'roll _id'); // <--- Just multiple fields name space separated // OR db.student.find({}).select('roll _id'); // <--- Just multiple fields name space separated // OR db.student.find({}, {'roll' : 1 , '_id' : 1 ); // <---- Old l... Add solution -
Javascript 2021-09-09 10:36:02
export mongo to csv node
const json2csv = require('json2csv').parse; //For unique file name const dateTime = new Date().toISOString().slice(-24).replace(/\D/g, '').slice(0, 14); const filePath = path.join(__dirname, "../../../", "public", "exports&quo... Add solution