Skip to content

Commit

Permalink
fix(db): throw readable error when creating _id with background: true
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 authored and mbroadst committed Jun 18, 2018
1 parent c699603 commit aac47a1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/db.js
Expand Up @@ -1042,14 +1042,16 @@ var createIndex = function(self, name, fieldOrSpec, options, callback) {
// 86 = 'IndexKeySpecsConflict' (index already exists with the same name)
// 11000 = 'DuplicateKey' (couldn't build unique index because of dupes)
// 11600 = 'InterruptedAtShutdown' (interrupted at shutdown)
// 197 = 'InvalidIndexSpecificationOption' (`_id` with `background: true`)
// These errors mean that the server recognized `createIndex` as a command
// and so we don't need to fallback to an insert.
if (
err.code === 67 ||
err.code === 11000 ||
err.code === 85 ||
err.code === 86 ||
err.code === 11600
err.code === 11600 ||
err.code === 197
) {
return handleCallback(callback, err, result);
}
Expand Down

0 comments on commit aac47a1

Please sign in to comment.