@pi-r/azure 0.8.0 → 0.8.1

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/client/index.js CHANGED
@@ -183,7 +183,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
183
183
  const closeClient = () => client?.dispose();
184
184
  for (let i = 0; i < length; ++i) {
185
185
  const item = batch[i];
186
- const { service, name, table, id, query, storedProcedureId, partitionKey = null, params, limit = 0, update, ignoreCache } = item;
186
+ const { service, name, table, id, query, storedProcedureId, partitionKey = null, params, limit = 0, ignoreCache } = item;
187
187
  if (!name || !table) {
188
188
  closeClient();
189
189
  throw (0, util_1.formatError)(item, name ? "Missing database table" : "Missing database name");
@@ -202,7 +202,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
202
202
  }
203
203
  }
204
204
  else if (id) {
205
- const { options } = item;
205
+ const { update, options } = item;
206
206
  if (queryString) {
207
207
  queryString += (partitionKey ? Cloud.asString(partitionKey, true) : '') + '_' + id + '_' + Cloud.asString(options, true);
208
208
  if (!update && (rows = this.getCacheResult(service, credential, queryString, cacheValue, ignoreCache))) {
@@ -217,19 +217,25 @@ async function executeBatchQuery(credential, batch, sessionKey) {
217
217
  }
218
218
  }
219
219
  else {
220
- let { options } = item;
220
+ const { update, options = {} } = item;
221
221
  if (partitionKey) {
222
- (options ||= {}).partitionKey = partitionKey;
222
+ options.partitionKey = partitionKey;
223
223
  }
224
224
  if (limit > 0) {
225
- (options ||= {}).maxItemCount = limit;
225
+ options.maxItemCount = limit;
226
226
  }
227
- if (query || (0, types_1.isPlainObject)(options)) {
228
- if (queryString && (rows = this.getCacheResult(service, credential, queryString += (query ? Cloud.asString(query, true) : '') + Cloud.asString(options, true), cacheValue, ignoreCache))) {
229
- result[i] = rows;
230
- continue;
227
+ if (query || Object.keys(options).length > 0) {
228
+ if (queryString) {
229
+ queryString += (query ? Cloud.asString(query, true) : '') + Cloud.asString(options, true);
230
+ if (!update && (rows = this.getCacheResult(service, credential, queryString, cacheValue, ignoreCache))) {
231
+ result[i] = rows;
232
+ continue;
233
+ }
231
234
  }
232
235
  const items = createClient(name, table).items;
236
+ if (update) {
237
+ await items.upsert(update, { accessCondition: options.accessCondition, sessionToken: options.sessionToken, initialHeaders: options.initialHeaders, priorityLevel: options.priorityLevel });
238
+ }
233
239
  ({ resources: rows } = await (query ? items.query(query, options).fetchAll() : items.readAll(options).fetchAll()));
234
240
  }
235
241
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/azure",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Azure cloud functions for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "publishConfig": {
package/types/index.d.ts CHANGED
@@ -11,7 +11,7 @@ export interface AzureStorageCredential {
11
11
  sharedAccessSignature?: string;
12
12
  }
13
13
 
14
- export interface AzureDatabaseQuery<T = FeedOptions | RequestOptions> extends CloudDatabase<string | SqlQuerySpec, T, PatchRequestBody, unknown[], AzureDatabaseCredential> {
14
+ export interface AzureDatabaseQuery<T = FeedOptions | RequestOptions, U = PatchRequestBody | PlainObject> extends CloudDatabase<string | SqlQuerySpec, T, U, unknown[], AzureDatabaseCredential> {
15
15
  source: "cloud";
16
16
  service: "azure" | "az";
17
17
  partitionKey?: PartitionKey;