You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The index key_1 already exists in the DB, but the function call ObjectKey.syncIndexes() throws an error:
MongoServerError: An existing index has the same name as the requested index. When index names are not specified, they are auto generated and can cause conflicts. Please refer to our documentation. Requested index: { v: 2, key: { key: 1 }, name: "key_1", background: true }, existing index: { v: 2, unique: true, key: { key: 1 }, name: "key_1", background: true }
at Connection.sendCommand (/data/node_modules/mongodb/lib/cmap/connection.js:289:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Connection.command (/data/node_modules/mongodb/lib/cmap/connection.js:312:26)
at async Server.command (/data/node_modules/mongodb/lib/sdam/server.js:167:29)
at async CreateIndexesOperation.executeCommand (/data/node_modules/mongodb/lib/operations/command.js:73:16)
at async CreateIndexesOperation.execute (/data/node_modules/mongodb/lib/operations/indexes.js:122:9)
at async tryOperation (/data/node_modules/mongodb/lib/operations/execute_operation.js:192:20)
at async executeOperation (/data/node_modules/mongodb/lib/operations/execute_operation.js:69:16)
at async Collection.createIndex (/data/node_modules/mongodb/lib/collection.js:326:25) {
errorResponse: {
ok: 0,
errmsg: 'An existing index has the same name as the requested index. When index names are not specified, they are auto generated and can cause conflicts. Please refer to our documentation. Requested index: { v: 2, key: { key: 1 }, name: "key_1", background: true }, existing index: { v: 2, unique: true, key: { key: 1 }, name: "key_1", background: true }',
code: 86,
codeName: 'IndexKeySpecsConflict',
'$clusterTime': {
clusterTime: new Timestamp({ t: 1732303578, i: 14 }),
signature: [Object]
},
operationTime: new Timestamp({ t: 1732303578, i: 14 })
},
ok: 0,
code: 86,
codeName: 'IndexKeySpecsConflict',
'$clusterTime': {
clusterTime: new Timestamp({ t: 1732303578, i: 14 }),
signature: {
hash: Binary.createFromBase64('OIA61Np4Zxmq4QBf1Ih5rquR7m0=', 0),
keyId: new Long('7398342335731335169')
}
},
operationTime: new Timestamp({ t: 1732303578, i: 14 }),
[Symbol(errorLabels)]: Set(0) {}
}
Steps to Reproduce
Create schema
Run syncIndex()
Expected Behavior
Should ignore creating existing index.
The text was updated successfully, but these errors were encountered:
Prerequisites
Mongoose version
8.7.0
Node.js version
18.18.0
MongoDB server version
6.0.19
Typescript version (if applicable)
No response
Description
Schema
The index key_1 already exists in the DB, but the function call ObjectKey.syncIndexes() throws an error:
Steps to Reproduce
Expected Behavior
Should ignore creating existing index.
The text was updated successfully, but these errors were encountered: