Skip to content

Commit b3ff3ed

Browse files
committed
fix(db): throw readable error when creating _id with background: true
1 parent ad03190 commit b3ff3ed

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/operations/db_ops.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,15 @@ function createIndex(db, name, fieldOrSpec, options, callback) {
278278
* 86 = 'IndexKeySpecsConflict' (index already exists with the same name)
279279
* 11000 = 'DuplicateKey' (couldn't build unique index because of dupes)
280280
* 11600 = 'InterruptedAtShutdown' (interrupted at shutdown)
281+
* 197 = 'InvalidIndexSpecificationOption' (`_id` with `background: true`)
281282
*/
282283
if (
283284
err.code === 67 ||
284285
err.code === 11000 ||
285286
err.code === 85 ||
286287
err.code === 86 ||
287-
err.code === 11600
288+
err.code === 11600 ||
289+
err.code === 197
288290
) {
289291
return handleCallback(callback, err, result);
290292
}

0 commit comments

Comments
 (0)