-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scoped counter with more than one reference counter fails with duplicate key #44
Comments
It seems that I created the fix but never merged it. I'll look at this sonn, probably the beginning of the next week and I'll create a new major version to fix the issue |
I just published version 5.0.0 |
hi Favrizio, Thanks for your fast reaction. I have made extensive tests importing a large quantity of documents with multiple variations of the customer and establishment reference and it worked as a charm. Thank you very much. Great plugin. |
Happy to hear! Btw,you never spelled my name correctly 😂 |
sorry for this Fabrizio, v and b are next to each others on my keyboard ! |
I have the requirement to keep unique sequence counter per establishment per company in an employee document.
I have specified the following using your plugin :
EmployeeSchema.plugin( AutoIncrement, { id: 'employees_counter', inc_field: 'sequence', reference_fields: ['customer', 'establishment'] } );
Inserting multiple documents with customer = '5c5498941f17864d225d18d4' and establishement = '85520050700017' works just fine a document is created in the Counters document with the following values.
Resetting the counter works fine ( as per my previous issue ).
But when I want to insert a document that has a different a different establishement value for the same customer value, the insert is rejected with a duplicate key in the Counter
MongoError: E11000 duplicate key error collection: moncse.counters index: id_1_reference_value_1 dup key: { : "employees_counter", : ""5c5498941f17864d225d18d4"" }
I have read issue #34 and thought that the pb was fixed. It seems not.
This render you plug-in unusable for me if the pb is not fixed.
The text was updated successfully, but these errors were encountered: