@teamkeel/functions-runtime 0.293.1 → 0.293.2

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.293.1",
3
+ "version": "0.293.2",
4
4
  "description": "Internal package used by @teamkeel/sdk",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
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`)
@@ -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)) {
package/src/casing.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const { snakeCase, camelCase } = require("change-case");
2
2
 
3
- function camelCaseObject(obj) {
3
+ function camelCaseObject(obj = {}) {
4
4
  const r = {};
5
5
  for (const key of Object.keys(obj)) {
6
6
  r[camelCase(key)] = obj[key];