terrier-engine 4.72.1 → 4.72.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 CHANGED
@@ -4,7 +4,7 @@
4
4
  "files": [
5
5
  "*"
6
6
  ],
7
- "version": "4.72.1",
7
+ "version": "4.72.3",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Terrier-Tech/terrier-engine"
@@ -285,6 +285,26 @@ export default class DbClient<PM extends ModelTypeMap, UM extends ModelTypeMap,
285
285
  }
286
286
  }
287
287
 
288
+ /**
289
+ * Partially update the given record and assume it will succeed.
290
+ * This call should be wrapped in a try/catch.
291
+ * @param modelType the camel_case name of the model
292
+ * @param id the id of the record
293
+ * @param record the record to update
294
+ * @param includes relations to include in the returned record
295
+ */
296
+ async safePartialUpdate<T extends keyof PM & string>(modelType: T, id: string, record: PartialRecord<UM[T]>, includes: Includes<PM,T,I> = {}): Promise<PM[T]> {
297
+ const res = await this.partialUpdate(modelType, id, record, includes)
298
+ if (res.status == 'success') {
299
+ return res.record
300
+ } else if (res.record) {
301
+ throw new DbSaveException<PM, T>(res.message, res.record as UM[T], res.errors)
302
+ } else {
303
+ throw `Error updating ${modelType}: ${res.message}`
304
+ }
305
+ }
306
+
307
+
288
308
  /**
289
309
  * Inserts a new record for the given model type.
290
310
  * @param modelType the camel_case name of the model