@teamkeel/functions-runtime 0.238.0 → 0.240.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamkeel/functions-runtime",
3
- "version": "0.238.0",
3
+ "version": "0.240.0",
4
4
  "description": "Internal package used by @teamkeel/sdk",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/ModelAPI.js CHANGED
@@ -39,13 +39,19 @@ class ModelAPI {
39
39
  }
40
40
 
41
41
  async findMany(where) {
42
- const rows = await this._db
42
+ let query = this._db
43
43
  .selectFrom(this._tableName)
44
- .selectAll()
45
- .where((qb) => {
44
+ .selectAll();
45
+
46
+ // only apply constraints if there are keys in the where
47
+ if (Object.keys(where).length > 0) {
48
+ query = query.where((qb) => {
46
49
  return applyWhereConditions(qb, where);
47
50
  })
48
- .execute();
51
+ }
52
+
53
+ const rows = await query.execute();
54
+
49
55
  return rows.map((x) => camelCaseObject(x));
50
56
  }
51
57
 
@@ -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",