I am trying to insert a document into my Mongo Database using the package mongo_dart
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",
});
Runtime error on line 4
Unhandled Exception: type 'ObjectId' is not a subtype of type 'String' of 'value'
Is it an issue with the package or is something wrong with my code?
3
Answers
try this one
Are you using the latest version of the package?
I think your problem is related to this issue in the GitHub Repo of the package but it is closed at Jul 25, 2015.
The error is arising because you declared variables
db
and (collection name) outside thestatic connect() async
function; declare them inside the function.