SamVerschueren / dynongo

MongoDB like syntax for DynamoDB
MIT License
58 stars 16 forks source link

feat: Add $ifNotExists tot $set operator #85

Closed onhate closed 3 years ago

onhate commented 3 years ago

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 commented 3 years ago

@SamVerschueren what do you think about this one?

codecov-io commented 3 years ago

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 commented 3 years ago

@SamVerschueren ?

onhate commented 3 years ago

onhate commented 3 years ago

@SamVerschueren ?