-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feat/promotions create auto increment function for generating auto-increment Ids #6645
feat/promotions create auto increment function for generating auto-increment Ids #6645
Conversation
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple general comments:
- A couple Jest tests might be nice to prove it works
- Readme could show a usage example
- There is not much code here. Should this be built into core and available always on context similar to
getAbsoluteUrl
?
export const Sequence = new SimpleSchema({ | ||
shopId: String, | ||
entity: String, | ||
value: SimpleSchema.Integer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding min: 0
validation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aldeed Could not think of what to write tests for since it relies to heavily on the db which would need to mocked
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
…ment-id Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
…-auto-increment-id feat/promotions create auto increment function for generating auto-increment Ids
Resolves reactioncommerce/kinetic#107
Impact: minor
Type: feature
Issue
Unlike most SQL databases Mongo does not have a built in function for creating auto-incrementing IDs
Solution
Using
findOneAndUpdate
and$inc
is a fully atomic operation that is not subject to race-conditions and thus works as an equivalent. Please read that again for commenting, nerds.Breaking changes
None