|
|
|
สอบถามเรื่อง nodejs,mongodb ต้องการเรียนแล้วอัพเดท collection ครับ |
|
|
|
|
|
|
|
Code (JavaScript)
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://127.0.0.1:27017/";
MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("mydb");
var myquery = { address: /^S/ };
var newvalues = {$set: {name: "Minnie"} };
dbo.collection("customers").updateMany(myquery, newvalues, function(err, res) {
if (err) throw err;
console.log(res.result.nModified + " document(s) updated");
db.close();
});
});
https://www.w3schools.com/nodejs/nodejs_mongodb_update.asp
|
|
|
|
|
Date :
2020-08-02 23:11:29 |
By :
PhrayaDev |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (JavaScript)
let data1 = model1.findOne({xxx:value}).exec();
if(data1){
let data2 = mode2.findOne({model1._id:data1._id}).exec();
data2.status=1
data2.save()
}
|
|
|
|
|
Date :
2021-06-11 00:58:10 |
By :
mongkon.k |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|