-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.2.7
-
Component/s: None
-
Environment:Client Linux Nodejs v11.9.0
Server https://cloud.mongodb.com
No mongoose, mongodb 3.2.7 only
No transpiling
-
Empty show more show less
Hi!
While NODE-1641 was fixed for createIndex and it works as expected,
I have the same issue as described in that bug report, but for createIndexes.
let messages = db.collection('messages');
await messages.createIndexes([{ userId: 1 }, { sessionId: 1 }]);
messages.createIndexes (node:4505) UnhandledPromiseRejectionWarning: MongoError: The field 'userId' is not valid for an index specification. Specification: { userId: 1, name: "" } at Connection.<anonymous> (/home/gor/Development/GorShoppingBot/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:443:61) at Connection.emit (events.js:196:13) at processMessage (/home/gor/Development/GorShoppingBot/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:364:10) at TLSSocket.<anonymous> (/home/gor/Development/GorShoppingBot/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:533:15) at TLSSocket.emit (events.js:196:13) at addChunk (_stream_readable.js:290:12) at readableAddChunk (_stream_readable.js:271:11) at TLSSocket.Readable.push (_stream_readable.js:226:10) at TLSWrap.onStreamRead (internal/stream_base_commons.js:166:17)
I have mongodb js client v3.2.7 and connect to Atlas.