@cellaware/utils 5.3.4 → 5.3.5

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.
@@ -92,3 +92,7 @@ export declare function cosmosDelete(databaseId: string, collectionId: string, p
92
92
  * Will only update a **single** record. If multiple records are returned from `query`, we will only update the first one.
93
93
  */
94
94
  export declare function cosmosUpdate(databaseId: string, collectionId: string, partitionKey: string, query: string, data: any): Promise<boolean>;
95
+ /**
96
+ * Simply deletes an existing record(s) then inserts a new one.
97
+ */
98
+ export declare function cosmosUpsert(databaseId: string, collectionId: string, partitionKey: string, query: string, data: any): Promise<boolean>;
@@ -247,3 +247,14 @@ export async function cosmosUpdate(databaseId, collectionId, partitionKey, query
247
247
  return false;
248
248
  }
249
249
  }
250
+ /**
251
+ * Simply deletes an existing record(s) then inserts a new one.
252
+ */
253
+ export async function cosmosUpsert(databaseId, collectionId, partitionKey, query, data) {
254
+ const delRes = await cosmosDelete(databaseId, collectionId, partitionKey, query);
255
+ if (!delRes) {
256
+ return delRes;
257
+ }
258
+ const insRes = await cosmosInsert(databaseId, collectionId, partitionKey, data);
259
+ return insRes;
260
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "5.3.4",
3
+ "version": "5.3.5",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",