question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conflict error for compound indexes is not correct

See original GitHub issue

Steps to reproduce

  1. Create a compound index for your collection:
const mongoose = require('mongoose')

const schema = new mongoose.Schema({
  // random fields used as an example
  firstId: { type: mongoose.Types.ObjectId },
  secondId: { type: mongoose.Types.ObjectId }
})

schema.index({ firstId: 1, secondId: 1 }, { unique: true })
  1. Create two documents, both with the same firstId and secondId field values and inspect the error message returned from mongoose. It will look something like this: firstId: ObjectId(\'5b891cf30d74a9432c0ee036\'), : ObjectId(\'587775b068194a6b3c818dce\') already exists.

Expected behavior

Feathers mongoose should handle a 1100 or 11001 MongoDB error and display a useful error message for the user of the library

Actual behavior

This works fine for regular indexes, but when there is a compound index the error message is rather obscure.

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that’s not working): feathers-mongoose: 6.1.2 mongoose: 4.13.14

NodeJS version: 8.11.2

Operating System: Ubuntu 16.04

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
dafflcommented, Jan 14, 2019

We probably could do the same thing the new Sequelize adapter is doing and add a hidden property with the original error (https://github.com/feathersjs-ecosystem/feathers-sequelize#migrating).

0reactions
dafflcommented, Jan 14, 2019

It basically just adds the original error in a Symbol error property (see https://github.com/feathersjs-ecosystem/feathers-sequelize/blob/master/lib/utils.js) so it can be accessed and used in the server-side error handler.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MongoDB Query plan not using compound index
I have created two indexes i.e one on child_comp field and the other one is a compound index with parent_comp, child_comp, and ...
Read more >
How to make ON CONFLICT work for compound foreign key ...
The optional ON CONFLICT clause specifies an alternative action to raising a unique violation or exclusion constraint violation error.
Read more >
Compound Indexes — MongoDB Manual
You will receive an error if you attempt to create a compound index that contains more than one hashed index field. In MongoDB...
Read more >
Want MongoDB Performance? You Will Need to Add and ...
Talking about MongoDB performance, having too many indexes, and finding both duplicate and unused indexes.
Read more >
Azure Cosmos DB indexing policies | Microsoft Learn
Setting this property to true allows Azure Cosmos DB to automatically ... By default, no composite indexes are defined so you should add ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found