Skip to content

Commit

Permalink
[FEAT] Adicionando novo operador (#258)
Browse files Browse the repository at this point in the history
* feat(dao): ✨ new operator dynamic filters

* fix(deepsource): 🚑 fixes

---------

Co-authored-by: Lucas <[email protected]>
  • Loading branch information
LuquinhasSG and Lucas authored Apr 18, 2024
1 parent 59b55a1 commit 481e28c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adapcon-utils-js",
"version": "1.3.7",
"version": "1.3.8",
"description": "Utils library for Javascript",
"keywords": [],
"author": {
Expand Down
11 changes: 10 additions & 1 deletion src/dao/dynamo/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const query = async <T>({
return items
}

async function scan<T>(params: ScanCommandInput): Promise<ScanOutput<T>> {
async function scan<T> (params: ScanCommandInput): Promise<ScanOutput<T>> {
const command = new ScanCommand(params)
const result = await documentInstance.send(command)

Expand Down Expand Up @@ -319,6 +319,15 @@ const dynamicFilters = ({
newExpressionAttributeNames[`#filter_${index}`] = field
newExpressionAttributeValues[`:filter_between_0_${index}`] = start
newExpressionAttributeValues[`:filter_between_1_${index}`] = end
} else if (operator === 'IN') {
const inValues = value.map((_, i: number) => `:filter_in_${index}_${i}`)
const values: string = inValues.join(', ')
filterExpression.push(`#filter_${index} ${operator} (${values})`)

newExpressionAttributeNames[`#filter_${index}`] = field
value.forEach((v: string, i: number) => {
newExpressionAttributeValues[`:filter_in_${index}_${i}`] = v
})
} else {
filterExpression.push(`#filter_${index} ${operator} :filter_${index}`)

Expand Down

0 comments on commit 481e28c

Please sign in to comment.