-
Notifications
You must be signed in to change notification settings - Fork 30
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: generate id field using uuid #191
base: main
Are you sure you want to change the base?
feat: generate id field using uuid #191
Conversation
Codecov Report
@@ Coverage Diff @@
## main #191 +/- ##
=======================================
Coverage 68.75% 68.75%
=======================================
Files 28 28
Lines 560 560
=======================================
Hits 385 385
Misses 175 175
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -54,7 +54,8 @@ module.exports = | |||
'"nodemon": "^2.0.19"', | |||
'"mocha": "^10.0.0"', | |||
'"lodash.camelcase": "^4.3.0"', | |||
'"sugar-env": "^1.5.14"' | |||
'"sugar-env": "^1.5.14"', | |||
'"uuid": "^9.0.0"' |
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.
Can we use the native uuid?
https://nodejs.org/api/crypto.html#cryptorandomuuidoptions
const dependency = { <%- props.name.pascalCase %>Repository } | ||
|
||
const create<%- props.name.pascalCase %> = injection => | ||
usecase('Create <%- props.name.pascalCase %>', { | ||
// Input/Request metadata and validation | ||
// Input/Request metadata and 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.
Let's try to avoid unnecessary merges (spaces, tabs, etc)
<% if(!props.mongo){ %>ctx.<%- props.name.camelCase %>.id = Math.floor(Math.random() * 100000).toString()<% } %> | ||
|
||
if (!ctx.<%- props.name.camelCase %>.isValid()) | ||
ctx.<%- props.name.camelCase %>.id = uuid.v4() |
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.
it seems a mongo if
was removed. is it working with mongo?
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.
Yes. Worked perfectly
Thanks @rodrigodosanjosoliveira for the contribution |
On the migrations you would need something like this: |
Fixes #158
Proposed Changes
Readiness Checklist
Author/Contributor
Reviewing Maintainer
breaking
if this is a large fundamental changeautomation
,bug
,documentation
,enhancement
,infrastructure
, orperformance