找不到指定_id的项,是因为默认的生成是ObjectId对象,
不是加字符串前后缀能解决的
解决方式👇👇👇 : 🌺引用mongodb内部暴露出的ObjectId()方法获取预期对象
const {MongoClient, ObjectId} = require('mongodb')
let url = 'mongodb://localhost:27017';
let collection = null;
MongoClient.connect(url, (err, db) => {
collection = db.db('api').collection("api_collection");
let whereStr = {"_id": ObjectId(_id)};
var updateStr = {$set: { "contentType":"new contentType", "name": "new name"}};
collection.updateOne(whereStr, updateStr, (err, result) => {
})
})