From 44a40aef96630664d226b37209c23e85a7338de3 Mon Sep 17 00:00:00 2001 From: Eric Tuvesson Date: Thu, 13 Jun 2024 22:24:05 +0200 Subject: [PATCH] fix: Add more error handling to JavaScript Records API (#33) --- packages/noodl-runtime/src/api/records.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/noodl-runtime/src/api/records.js b/packages/noodl-runtime/src/api/records.js index 7cc72cb..f73cd3f 100644 --- a/packages/noodl-runtime/src/api/records.js +++ b/packages/noodl-runtime/src/api/records.js @@ -12,6 +12,7 @@ function createRecordsAPI(modelScope) { return { async query(className, query, options) { + if (typeof className === "undefined") throw new Error("'className' is undefined"); return new Promise((resolve, reject) => { cloudstore().query({ collection: className, @@ -39,6 +40,7 @@ function createRecordsAPI(modelScope) { }, async count(className, query) { + if (typeof className === "undefined") throw new Error("'className' is undefined"); return new Promise((resolve, reject) => { cloudstore().count({ collection: className, @@ -60,6 +62,7 @@ function createRecordsAPI(modelScope) { }, async distinct(className, property, query) { + if (typeof className === "undefined") throw new Error("'className' is undefined"); return new Promise((resolve, reject) => { cloudstore().distinct({ collection: className, @@ -82,6 +85,7 @@ function createRecordsAPI(modelScope) { }, async aggregate(className, group, query) { + if (typeof className === "undefined") throw new Error("'className' is undefined"); return new Promise((resolve, reject) => { cloudstore().aggregate({ collection: className, @@ -179,6 +183,7 @@ function createRecordsAPI(modelScope) { }, async create(className, properties, options) { + if (typeof className === "undefined") throw new Error("'className' is undefined"); return new Promise((resolve, reject) => { cloudstore().create({ collection: className,