Fri Jun 10 2022 16:55:15 GMT+0000 (UTC)
Saved by @guillecook #mongoshell
db.question.find().forEach( function(myDoc) { if (myDoc.comment){ db.question.updateOne( { "_id": myDoc._id }, { "$set": { "comment": myDoc.comment.trim() } } ); } } )
#javascript #mongoshell
db.Foo.aggregate( {$unwind: "$bars"}, {$lookup: { from:"bar", localField: "bars", foreignField: "_id", as: "bar" }}, {$match: { "bar.testprop": true }} )
#mongoshell
db.resolution.updateMany( { attach_pdf: { $regex: /.*564\..*/ } }, [{ $set: { attach_pdf: { $replaceOne: { input: "$attach_pdf", find: "564. Luxacion de muñeca.docx", replacement: "564. Luxacion de muneca.docx" } }} }] )
db.setProfilingLevel(0) db.system.profile.drop() db.setProfilingLevel(2)
#typescript #mongoshell
String.prototype.interpolate = function(params) { const names = Object.keys(params); const vals = Object.values(params); return new Function(...names, `return \`${this}\`;`)(...vals); } const template = 'Example text: ${text}'; const result = template.interpolate({ text: 'Foo Boo' }); console.log(result);
db.getCollection('Transaction').aggregate([ {"$group" : { "_id": "$transactionNo", "count": { "$sum": 1 }, "ids":{"$push":"$_id"} } }, {"$match": {"_id" :{ "$ne" : null } , "count" : {"$gt": 1} } } ])
db.getCollection('AccountSummary').createIndex({txDate: NumberInt(1)}); db.getCollection('AccountSummary').createIndex({jobId:NumberInt(1)}); db.getCollection('AccountSummary').createIndex({userId:NumberInt(1)}); db.getCollection('AccountSummary').createIndex({isActive:NumberInt(1)});
Copy this HTML code:
Preview:
open_in_newInstructions on embedding in Medium
Comments