Skip to content
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: Add $ifNotExists tot $set operator #85

Merged
merged 2 commits into from
Jan 28, 2021
Merged

feat: Add $ifNotExists tot $set operator #85

merged 2 commits into from
Jan 28, 2021

Conversation

onhate
Copy link
Collaborator

@onhate onhate commented Dec 26, 2020

Allow to set a value only if it does not exists on the record, a good use case is on upsert and setting a createdAt property

{ $set:  { createdAt: { $ifNotExists: date() } } }

https://docs.amazonaws.cn/en_us/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html#Expressions.UpdateExpressions.SET.PreventingAttributeOverwrites

extra: allow undefined/null where clause (to be ignored)

@onhate
Copy link
Collaborator Author

onhate commented Dec 26, 2020

@SamVerschueren what do you think about this one?

@codecov-io
Copy link

codecov-io commented Dec 26, 2020

Codecov Report

Merging #85 (3506247) into master (4080422) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #85      +/-   ##
==========================================
+ Coverage   96.89%   96.94%   +0.04%     
==========================================
  Files          34       34              
  Lines         645      654       +9     
  Branches       48       49       +1     
==========================================
+ Hits          625      634       +9     
  Misses         12       12              
  Partials        8        8              
Impacted Files Coverage Δ
src/lib/methods/base-query.ts 100.00% <100.00%> (ø)
src/lib/methods/delete-item.ts 100.00% <100.00%> (ø)
src/lib/methods/update-item.ts 100.00% <100.00%> (ø)
src/lib/utils/update.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4080422...3506247. Read the comment docs.

@onhate
Copy link
Collaborator Author

onhate commented Jan 11, 2021

@SamVerschueren ?

@onhate
Copy link
Collaborator Author

onhate commented Jan 19, 2021

@onhate
Copy link
Collaborator Author

onhate commented Jan 26, 2021

@SamVerschueren ?

Copy link
Owner

@SamVerschueren SamVerschueren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome job @onhate!

@SamVerschueren SamVerschueren changed the title feat: $set $ifNotExists feat: Add $ifNotExists tot $set operator Jan 28, 2021
@SamVerschueren SamVerschueren merged commit 9eafc2d into SamVerschueren:master Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants