Conflict error for compound indexes is not correct
See original GitHub issueSteps to reproduce
- 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 })
- Create two documents, both with the same
firstId
andsecondId
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:
- Created 5 years ago
- Comments:12 (11 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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).
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.