@teamkeel/functions-runtime 0.239.0 → 0.240.1
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 +10 -6
- package/src/ModelAPI.test.js +13 -0
package/package.json
CHANGED
package/src/ModelAPI.js
CHANGED
|
@@ -39,13 +39,17 @@ class ModelAPI {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
async findMany(where) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
let query = this._db.selectFrom(this._tableName).selectAll();
|
|
43
|
+
|
|
44
|
+
// only apply constraints if there are keys in the where
|
|
45
|
+
if (Object.keys(where).length > 0) {
|
|
46
|
+
query = query.where((qb) => {
|
|
46
47
|
return applyWhereConditions(qb, where);
|
|
47
|
-
})
|
|
48
|
-
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const rows = await query.execute();
|
|
52
|
+
|
|
49
53
|
return rows.map((x) => camelCaseObject(x));
|
|
50
54
|
}
|
|
51
55
|
|
package/src/ModelAPI.test.js
CHANGED
|
@@ -107,6 +107,19 @@ test("ModelAPI.findMany", async () => {
|
|
|
107
107
|
expect(rows.map((x) => x.id).sort()).toEqual([bob.id, sally.id].sort());
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
+
test("ModelAPI.findMany - no where conditions", async () => {
|
|
111
|
+
const jim = await api.create({
|
|
112
|
+
name: "Jim",
|
|
113
|
+
});
|
|
114
|
+
await api.create({
|
|
115
|
+
name: "Bob",
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const rows = await api.findMany({});
|
|
119
|
+
|
|
120
|
+
expect(rows.length).toEqual(2);
|
|
121
|
+
});
|
|
122
|
+
|
|
110
123
|
test("ModelAPI.findMany - startsWith", async () => {
|
|
111
124
|
const jim = await api.create({
|
|
112
125
|
name: "Jim",
|