【发布时间】:2023-02-14 16:58:11
【问题描述】:
我正在尝试使用包 mongo_dart 将文档插入到我的 Mongo 数据库中
var db = await Db.create(MONGO_CONN_STRING);
await db.open();
var coll = db.collection('reports');
await coll.insertOne({
"username": "Tom",
"action": "test",
"dateTime": "today",
});
第 4 行的运行时错误
Unhandled Exception: type 'ObjectId' is not a subtype of type 'String' of 'value'
是包的问题还是我的代码有问题?
【问题讨论】:
-
嘿,你解决了吗?我也遇到同样的错误。当我像在 map {} 中那样传递数据时,它正在工作,但我将像
Map<String, dynamic> data这样的地图变量传递给insertOne(data)。它给出了错误