Skip to content

Commit b071d80

Browse files
authored
Merge pull request #235 from rush-db/fix/processing-create_many-result
Fix processing boolean response at createMany method
2 parents 27ce113 + 3bc1768 commit b071d80

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

.changeset/real-cars-help.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@rushdb/javascript-sdk': patch
3+
'rushdb-docs': patch
4+
'rushdb-core': patch
5+
'rushdb-dashboard': patch
6+
'rushdb-website': patch
7+
---
8+
9+
Fix processing boolean response at createMany method

packages/javascript-sdk/src/api/api.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,11 @@ export class RestAPI {
291291
// If `returnResult` was not explicitly set to `true`, `response.data` may be just `true`.
292292
// In that case, fallback to an empty array. Otherwise, map records to typed instances.
293293
const dbRecordInstances =
294-
(response.data as Array<DBRecord<S>>)?.map((r) => {
295-
return new DBRecordInstance<S>(r)
296-
}) ?? []
294+
isArray(response.data) ?
295+
(<Array<DBRecord<S>>>response.data)?.map((r) => {
296+
return new DBRecordInstance<S>(r)
297+
})
298+
: []
297299
return new DBRecordsArrayInstance<S>(dbRecordInstances, response.total)
298300
}
299301

0 commit comments

Comments
 (0)