@cellaware/utils 5.3.4 → 5.3.6
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/dist/azure/cosmos.d.ts
CHANGED
|
@@ -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>;
|
package/dist/azure/cosmos.js
CHANGED
|
@@ -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
|
+
}
|
|
@@ -15,3 +15,7 @@ export declare function chatwmsCosmosDelete(collectionId: string, query: string,
|
|
|
15
15
|
* Default `partitionKey` is '/clientId'
|
|
16
16
|
*/
|
|
17
17
|
export declare function chatwmsCosmosUpdate(collectionId: string, query: string, data: any, partitionKey?: string): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Default `partitionKey` is '/clientId'
|
|
20
|
+
*/
|
|
21
|
+
export declare function chatwmsCosmosUpsert(collectionId: string, query: string, data: any, partitionKey?: string): Promise<boolean>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cosmosDelete, cosmosInsert, cosmosSelect, cosmosUpdate } from "../../azure/cosmos.js";
|
|
1
|
+
import { cosmosDelete, cosmosInsert, cosmosSelect, cosmosUpdate, cosmosUpsert } from "../../azure/cosmos.js";
|
|
2
2
|
const DATABASE_ID = 'chatwms';
|
|
3
3
|
const PARTITION_KEY = '/clientId';
|
|
4
4
|
export const PRODUCT_PARTITION_KEY = '/productId';
|
|
@@ -26,3 +26,9 @@ export async function chatwmsCosmosDelete(collectionId, query, partitionKey) {
|
|
|
26
26
|
export async function chatwmsCosmosUpdate(collectionId, query, data, partitionKey) {
|
|
27
27
|
return cosmosUpdate(DATABASE_ID, collectionId, partitionKey ?? PARTITION_KEY, query, data);
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Default `partitionKey` is '/clientId'
|
|
31
|
+
*/
|
|
32
|
+
export async function chatwmsCosmosUpsert(collectionId, query, data, partitionKey) {
|
|
33
|
+
return cosmosUpsert(DATABASE_ID, collectionId, partitionKey ?? PARTITION_KEY, query, data);
|
|
34
|
+
}
|