-
Type: Improvement
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
What problem are you facing?
import { MongoClient } from 'mongodb'; const client = await MongoClient.connect('mongodb+srv://m001-student:m001-mongodb-basics@cluster0.ucdwm.mongodb.net/'); const docs = []; docs[1] = {}; // works for docs[0] = {} await client.db('test').collection('test').insertMany(docs); await client.close();
gives this error:
/tmp/node_modules/mongodb/lib/bulk/common.js:730 if ('insertOne' in op) { ^ TypeError: Cannot use 'in' operator to search for 'insertOne' in undefined at OrderedBulkOperation.raw (/tmp/node_modules/mongodb/lib/bulk/common.js:730:25) at BulkWriteOperation.execute (/tmp/node_modules/mongodb/lib/operations/bulk_write.js:24:22) at InsertManyOperation.execute (/tmp/node_modules/mongodb/lib/operations/insert.js:75:28) at Object.callback (/tmp/node_modules/mongodb/lib/operations/execute_operation.js:161:19) at processWaitQueue (/tmp/node_modules/mongodb/lib/sdam/topology.js:668:25) at Topology.selectServer (/tmp/node_modules/mongodb/lib/sdam/topology.js:330:9) at executeWithServerSelection (/tmp/node_modules/mongodb/lib/operations/execute_operation.js:136:14) at /tmp/node_modules/mongodb/lib/operations/execute_operation.js:47:13 at Object.maybePromise (/tmp/node_modules/mongodb/lib/utils.js:516:5) at Object.executeOperation (/tmp/node_modules/mongodb/lib/operations/execute_operation.js:16:20)
which is not particularly helpful in debugging what is happening.
What driver and relevant dependency versions are you using?
Latest (4.1.0).
Steps to reproduce?
See above.
- split from
-
MONGOSH-907 Error "TypeError: Cannot use 'in' operator to search for 'insertOne' in undefined"
- Closed