@teamkeel/functions-runtime 0.293.1 → 0.293.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/ModelAPI.js +2 -2
- package/src/ModelAPI.test.js +22 -0
- package/src/applyWhereConditions.js +1 -1
- package/src/casing.js +1 -1
package/package.json
CHANGED
package/src/ModelAPI.js
CHANGED
|
@@ -65,7 +65,7 @@ class ModelAPI {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
async findOne(where) {
|
|
68
|
+
async findOne(where = {}) {
|
|
69
69
|
let builder = this._db
|
|
70
70
|
.selectFrom(this._tableName)
|
|
71
71
|
.distinctOn(`${this._tableName}.id`)
|
|
@@ -84,7 +84,7 @@ class ModelAPI {
|
|
|
84
84
|
return camelCaseObject(row);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
async findMany(where) {
|
|
87
|
+
async findMany(where = {}) {
|
|
88
88
|
let builder = this._db
|
|
89
89
|
.selectFrom(this._tableName)
|
|
90
90
|
.distinctOn(`${this._tableName}.id`)
|
package/src/ModelAPI.test.js
CHANGED
|
@@ -357,6 +357,28 @@ test("ModelAPI.findMany - before", async () => {
|
|
|
357
357
|
expect(rows[0].id).toEqual(p.id);
|
|
358
358
|
});
|
|
359
359
|
|
|
360
|
+
test("ModelAPI.findMany - empty where", async () => {
|
|
361
|
+
const p = await personAPI.create({
|
|
362
|
+
date: new Date("2022-01-01"),
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
const p2 = await personAPI.create({
|
|
366
|
+
date: new Date("2022-01-02"),
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// with no param specified at all
|
|
370
|
+
const rows = await personAPI.findMany();
|
|
371
|
+
|
|
372
|
+
expect(rows.map((r) => r.id).sort()).toEqual([p, p2].map((r) => r.id).sort());
|
|
373
|
+
|
|
374
|
+
// with empty object
|
|
375
|
+
const rows2 = await personAPI.findMany({});
|
|
376
|
+
|
|
377
|
+
expect(rows2.map((r) => r.id).sort()).toEqual(
|
|
378
|
+
[p, p2].map((r) => r.id).sort()
|
|
379
|
+
);
|
|
380
|
+
});
|
|
381
|
+
|
|
360
382
|
test("ModelAPI.findMany - onOrBefore", async () => {
|
|
361
383
|
const p = await personAPI.create({
|
|
362
384
|
date: new Date("2022-01-01"),
|
|
@@ -26,7 +26,7 @@ const opMapping = {
|
|
|
26
26
|
* @param {Object} where
|
|
27
27
|
* @returns {import("kysely").Kysely}
|
|
28
28
|
*/
|
|
29
|
-
function applyWhereConditions(context, qb, where) {
|
|
29
|
+
function applyWhereConditions(context, qb, where = {}) {
|
|
30
30
|
const conf = context.tableConfig();
|
|
31
31
|
|
|
32
32
|
for (const key of Object.keys(where)) {
|