Skip to content

Commit

Permalink
fix(nukak-browser): check if ids are returned before use to delete them
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerpadilla committed Apr 18, 2023
1 parent f76f869 commit 463ff88
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 65 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"@commitlint/cli": "^17.6.1",
"@commitlint/config-conventional": "^17.6.1",
"@types/jest": "^29.5.0",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"concurrently": "^8.0.1",
"coveralls": "^3.1.1",
"eslint": "^8.38.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/nukak-express/src/querierMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ export function buildQuerierRouter<E>(entity: Type<E>, opts: ExtraOptions) {
try {
await querier.beginTransaction();
const founds = await querier.findMany(entity, req.query, [meta.id]);
if (!founds.length) {
return res.json({ data: [], count: 0 });
}
const ids = founds.map((found) => found[meta.id]);
const count = await querier.deleteMany(entity, { $filter: { [meta.id]: ids } }, { softDelete: !!req.query.softDelete });
await querier.commitTransaction();
Expand Down
2 changes: 1 addition & 1 deletion packages/nukak-mongo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@types/mongodb": "^4.0.6",
"@types/node": "^18.15.11",
"copyfiles": "^2.4.1",
"mongodb": "^5.2.0",
"mongodb": "^5.3.0",
"rimraf": "^5.0.0",
"typescript": "^5.0.4"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/nukak-mysql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@types/mysql": "^2.15.21",
"@types/node": "^18.15.11",
"copyfiles": "^2.4.1",
"mysql2": "^3.2.1",
"mysql2": "^3.2.3",
"rimraf": "^5.0.0",
"typescript": "^5.0.4"
},
Expand Down
122 changes: 61 additions & 61 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2634,14 +2634,14 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/eslint-plugin@npm:^5.58.0":
version: 5.58.0
resolution: "@typescript-eslint/eslint-plugin@npm:5.58.0"
"@typescript-eslint/eslint-plugin@npm:^5.59.0":
version: 5.59.0
resolution: "@typescript-eslint/eslint-plugin@npm:5.59.0"
dependencies:
"@eslint-community/regexpp": ^4.4.0
"@typescript-eslint/scope-manager": 5.58.0
"@typescript-eslint/type-utils": 5.58.0
"@typescript-eslint/utils": 5.58.0
"@typescript-eslint/scope-manager": 5.59.0
"@typescript-eslint/type-utils": 5.59.0
"@typescript-eslint/utils": 5.59.0
debug: ^4.3.4
grapheme-splitter: ^1.0.4
ignore: ^5.2.0
Expand All @@ -2654,67 +2654,67 @@ __metadata:
peerDependenciesMeta:
typescript:
optional: true
checksum: e5d76d43c466ebd4b552e3307eff72ab5ae8a0c09a1d35fa13b62769ac3336df94d9281728ab5aafd2c14a0a644133583edcd708fce60a9a82df1db3ca3b8e14
checksum: 3b2582fe7baa9bf7733be79c6e35a390806f91c8d5ba5b604f71cb3635fb36abc975b926195c3ef5c6a4018bb94f66e009d727e3af2ce8b92c96aa3ee9ed194a
languageName: node
linkType: hard

"@typescript-eslint/parser@npm:^5.58.0":
version: 5.58.0
resolution: "@typescript-eslint/parser@npm:5.58.0"
"@typescript-eslint/parser@npm:^5.59.0":
version: 5.59.0
resolution: "@typescript-eslint/parser@npm:5.59.0"
dependencies:
"@typescript-eslint/scope-manager": 5.58.0
"@typescript-eslint/types": 5.58.0
"@typescript-eslint/typescript-estree": 5.58.0
"@typescript-eslint/scope-manager": 5.59.0
"@typescript-eslint/types": 5.59.0
"@typescript-eslint/typescript-estree": 5.59.0
debug: ^4.3.4
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
peerDependenciesMeta:
typescript:
optional: true
checksum: 38681da48a40132c0538579c818ceef9ba2793ab8f79236c3f64980ba1649bb87cb367cd79d37bf2982b8bfbc28f91846b8676f9bd333e8b691c9befffd8874a
checksum: 1a442d6b776fc1dca4fe104bac77eae0a59b807ba11cef00dec8f5dbbc0fb4e5fc10519eac03dd94d52e4dd6d814800d0e5c0a3bd43eefce80d829c65ba47ad0
languageName: node
linkType: hard

"@typescript-eslint/scope-manager@npm:5.58.0":
version: 5.58.0
resolution: "@typescript-eslint/scope-manager@npm:5.58.0"
"@typescript-eslint/scope-manager@npm:5.59.0":
version: 5.59.0
resolution: "@typescript-eslint/scope-manager@npm:5.59.0"
dependencies:
"@typescript-eslint/types": 5.58.0
"@typescript-eslint/visitor-keys": 5.58.0
checksum: f0d3df5cc3c461fe63ef89ad886b53c239cc7c1d9061d83d8a9d9c8e087e5501eac84bebff8a954728c17ccea191f235686373d54d2b8b6370af2bcf2b18e062
"@typescript-eslint/types": 5.59.0
"@typescript-eslint/visitor-keys": 5.59.0
checksum: dd89cd34291f7674edcbe9628748faa61dbf7199f9776586167e81fd91b93ba3a7f0ddd493c559c0dbb805b58629858fae648d56550e8ac5330b2ed1802b0178
languageName: node
linkType: hard

"@typescript-eslint/type-utils@npm:5.58.0":
version: 5.58.0
resolution: "@typescript-eslint/type-utils@npm:5.58.0"
"@typescript-eslint/type-utils@npm:5.59.0":
version: 5.59.0
resolution: "@typescript-eslint/type-utils@npm:5.59.0"
dependencies:
"@typescript-eslint/typescript-estree": 5.58.0
"@typescript-eslint/utils": 5.58.0
"@typescript-eslint/typescript-estree": 5.59.0
"@typescript-eslint/utils": 5.59.0
debug: ^4.3.4
tsutils: ^3.21.0
peerDependencies:
eslint: "*"
peerDependenciesMeta:
typescript:
optional: true
checksum: 803f24daed185152bf86952d4acebb5ea18ff03db5f28750368edf76fdea46b4b0f8803ae0b61c0282b47181c9977113457b16e33d5d2cb33b13855f55c5e5b2
checksum: 811981ea117808315fe37ce8489ae6e20979f588cf0fdef2bd969d58c505ececff0bccf7957f3b178933028433ce28764ebc9fea32a35a4c2da81b5b1e98b454
languageName: node
linkType: hard

"@typescript-eslint/types@npm:5.58.0":
version: 5.58.0
resolution: "@typescript-eslint/types@npm:5.58.0"
checksum: 8622a73d73220c4a7111537825f488c0271272032a1d4e129dc722bc6e8b3ec84f64469b2ca3b8dae7da3a9c18953ce1449af51f5f757dad60835eb579ad1d2c
"@typescript-eslint/types@npm:5.59.0":
version: 5.59.0
resolution: "@typescript-eslint/types@npm:5.59.0"
checksum: 5dc608a867b07b4262a236a264a65e894f841388b3aba461c4c1a30d76a2c3aed0c6a1e3d1ea2f64cce55e783091bafb826bf01a0ef83258820af63da860addf
languageName: node
linkType: hard

"@typescript-eslint/typescript-estree@npm:5.58.0":
version: 5.58.0
resolution: "@typescript-eslint/typescript-estree@npm:5.58.0"
"@typescript-eslint/typescript-estree@npm:5.59.0":
version: 5.59.0
resolution: "@typescript-eslint/typescript-estree@npm:5.59.0"
dependencies:
"@typescript-eslint/types": 5.58.0
"@typescript-eslint/visitor-keys": 5.58.0
"@typescript-eslint/types": 5.59.0
"@typescript-eslint/visitor-keys": 5.59.0
debug: ^4.3.4
globby: ^11.1.0
is-glob: ^4.0.3
Expand All @@ -2723,35 +2723,35 @@ __metadata:
peerDependenciesMeta:
typescript:
optional: true
checksum: 51b668ec858db0c040a71dff526273945cee4ba5a9b240528d503d02526685882d900cf071c6636a4d9061ed3fd4a7274f7f1a23fba55c4b48b143344b4009c7
checksum: d80f2766e2830dc830b9f4f1b9e744e1e7a285ebe72babdf0970f75bfe26cb832c6623bb836a53c48f1e707069d1e407ac1ea095bd583807007f713ba6e2e0e1
languageName: node
linkType: hard

"@typescript-eslint/utils@npm:5.58.0":
version: 5.58.0
resolution: "@typescript-eslint/utils@npm:5.58.0"
"@typescript-eslint/utils@npm:5.59.0":
version: 5.59.0
resolution: "@typescript-eslint/utils@npm:5.59.0"
dependencies:
"@eslint-community/eslint-utils": ^4.2.0
"@types/json-schema": ^7.0.9
"@types/semver": ^7.3.12
"@typescript-eslint/scope-manager": 5.58.0
"@typescript-eslint/types": 5.58.0
"@typescript-eslint/typescript-estree": 5.58.0
"@typescript-eslint/scope-manager": 5.59.0
"@typescript-eslint/types": 5.59.0
"@typescript-eslint/typescript-estree": 5.59.0
eslint-scope: ^5.1.1
semver: ^7.3.7
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
checksum: c618ae67963ecf96b1492c09afaeb363f542f0d6780bcac4af3c26034e3b20034666b2d523aa94821df813aafb57a0b150a7d5c2224fe8257452ad1de2237a58
checksum: 228318df02f2381f859af184cafa5de4146a2e1518a5062444bf9bd7d468e058f9bd93a3e46cc4683d9bd02159648f416e5c7c539901ca16142456cae3c1af5f
languageName: node
linkType: hard

"@typescript-eslint/visitor-keys@npm:5.58.0":
version: 5.58.0
resolution: "@typescript-eslint/visitor-keys@npm:5.58.0"
"@typescript-eslint/visitor-keys@npm:5.59.0":
version: 5.59.0
resolution: "@typescript-eslint/visitor-keys@npm:5.59.0"
dependencies:
"@typescript-eslint/types": 5.58.0
"@typescript-eslint/types": 5.59.0
eslint-visitor-keys: ^3.3.0
checksum: ab2d1f37660559954c840429ef78bbf71834063557e3e68e435005b4987970b9356fdf217ead53f7a57f66f5488dc478062c5c44bf17053a8bf041733539b98f
checksum: e21656de02e221a27a5fe9f7fd34a1ca28530e47675134425f84fd0d1f276695fe39e35120837a491b02255d49aa2fd871e2c858ecccc66c687db972d057bd1c
languageName: node
linkType: hard

Expand Down Expand Up @@ -7333,17 +7333,17 @@ __metadata:
languageName: node
linkType: hard

"mongodb@npm:^5.2.0":
version: 5.2.0
resolution: "mongodb@npm:5.2.0"
"mongodb@npm:^5.3.0":
version: 5.3.0
resolution: "mongodb@npm:5.3.0"
dependencies:
bson: ^5.2.0
mongodb-connection-string-url: ^2.6.0
saslprep: ^1.0.3
socks: ^2.7.1
peerDependencies:
"@aws-sdk/credential-providers": ^3.201.0
mongodb-client-encryption: ^2.3.0
mongodb-client-encryption: ">=2.3.0 <3"
snappy: ^7.2.2
dependenciesMeta:
saslprep:
Expand All @@ -7355,7 +7355,7 @@ __metadata:
optional: true
snappy:
optional: true
checksum: 2114175fab6a56c2d2902d97117c98c7b240155af6b7880174dbdf90bdcd8eb60c959ced7ed8b6327abfe226d6ae9933356344fc7d6e71798fef86e6eddd0173
checksum: da86069555f3f700a0ef338a4676de2254ef64f7700427c0e23ccd5bd9ca9cd5f08651f2eb5083edfdc1e7eed1b40c60041b16e6d4851f353a26d9469d274299
languageName: node
linkType: hard

Expand Down Expand Up @@ -7387,9 +7387,9 @@ __metadata:
languageName: node
linkType: hard

"mysql2@npm:^3.2.1":
version: 3.2.1
resolution: "mysql2@npm:3.2.1"
"mysql2@npm:^3.2.3":
version: 3.2.3
resolution: "mysql2@npm:3.2.3"
dependencies:
denque: ^2.1.0
generate-function: ^2.3.1
Expand All @@ -7399,7 +7399,7 @@ __metadata:
named-placeholders: ^1.1.3
seq-queue: ^0.0.5
sqlstring: ^2.3.2
checksum: 54229b7ff53e99b774f3955e915893a5513bed61de8fa36fc739ec59b516f98e6411cf1e112105afbc904fed571ad16baf079f5cdbe523986034601aab35ab2c
checksum: 5b44b96cc2ae92c94c64573cc3a235e4e7a97b237bf22b8e8ab545c1acaf5cd2d24f7589d9a399c5d5641440ed68a11a272053791617c42a2ecbb32ee22b4465
languageName: node
linkType: hard

Expand Down Expand Up @@ -7738,7 +7738,7 @@ __metadata:
"@types/mongodb": ^4.0.6
"@types/node": ^18.15.11
copyfiles: ^2.4.1
mongodb: ^5.2.0
mongodb: ^5.3.0
rimraf: ^5.0.0
typescript: ^5.0.4
peerDependencies:
Expand All @@ -7754,7 +7754,7 @@ __metadata:
"@types/mysql": ^2.15.21
"@types/node": ^18.15.11
copyfiles: ^2.4.1
mysql2: ^3.2.1
mysql2: ^3.2.3
rimraf: ^5.0.0
sqlstring: ^2.3.3
typescript: ^5.0.4
Expand Down Expand Up @@ -8802,8 +8802,8 @@ __metadata:
"@commitlint/cli": ^17.6.1
"@commitlint/config-conventional": ^17.6.1
"@types/jest": ^29.5.0
"@typescript-eslint/eslint-plugin": ^5.58.0
"@typescript-eslint/parser": ^5.58.0
"@typescript-eslint/eslint-plugin": ^5.59.0
"@typescript-eslint/parser": ^5.59.0
concurrently: ^8.0.1
coveralls: ^3.1.1
eslint: ^8.38.0
Expand Down

0 comments on commit 463ff88

Please sign in to comment.