in src/table/batch/TableBatchOrchestrator.ts [245:348]
private async routeAndDispatchBatchRequest(
request: BatchRequest,
context: Context,
contentID: number,
batchId: string
): Promise<any> {
const batchContextClone = this.createBatchContextClone(
context,
request,
batchId
);
let response: any;
let __return: any;
// we only use 5 HTTP Verbs to determine the table operation type
try {
switch (request.getMethod()) {
case BatchStringConstants.VERB_POST:
// INSERT: we are inserting an entity
// POST https://myaccount.table.core.windows.net/mytable
({ __return, response } = await this.handleBatchInsert(
request,
response,
batchContextClone,
contentID,
batchId
));
break;
case BatchStringConstants.VERB_PUT:
// UPDATE: we are updating an entity
// PUT http://127.0.0.1:10002/devstoreaccount1/mytable(PartitionKey='myPartitionKey', RowKey='myRowKey')
// INSERT OR REPLACE:
// PUT https://myaccount.table.core.windows.net/mytable(PartitionKey='myPartitionKey', RowKey='myRowKey')
({ __return, response } = await this.handleBatchUpdate(
request,
response,
batchContextClone,
contentID,
batchId
));
break;
case BatchStringConstants.VERB_DELETE:
// DELETE: we are deleting an entity
// DELETE https://myaccount.table.core.windows.net/mytable(PartitionKey='myPartitionKey', RowKey='myRowKey')
({ __return, response } = await this.handleBatchDelete(
request,
response,
batchContextClone,
contentID,
batchId
));
break;
case BatchStringConstants.VERB_GET:
// QUERY : we are querying / retrieving an entity
// GET https://myaccount.table.core.windows.net/mytable(PartitionKey='<partition-key>',RowKey='<row-key>')?$select=<comma-separated-property-names>
({ __return, response } = await this.handleBatchQuery(
request,
response,
batchContextClone,
contentID,
batchId
));
break;
case BatchStringConstants.VERB_CONNECT:
throw new Error("Connect Method unsupported in batch.");
break;
case BatchStringConstants.VERB_HEAD:
throw new Error("Head Method unsupported in batch.");
break;
case BatchStringConstants.VERB_OPTIONS:
throw new Error("Options Method unsupported in batch.");
break;
case BatchStringConstants.VERB_TRACE:
throw new Error("Trace Method unsupported in batch.");
break;
case BatchStringConstants.VERB_PATCH:
// this is using the PATCH verb to merge
({ __return, response } = await this.handleBatchMerge(
request,
response,
batchContextClone,
contentID,
batchId
));
break;
default:
// MERGE: this must be the merge, as the merge operation is not currently generated by autorest
// MERGE https://myaccount.table.core.windows.net/mytable(PartitionKey='myPartitionKey', RowKey='myRowKey')
// INSERT OR MERGE
// MERGE https://myaccount.table.core.windows.net/mytable(PartitionKey='myPartitionKey', RowKey='myRowKey')
({ __return, response } = await this.handleBatchMerge(
request,
response,
batchContextClone,
contentID,
batchId
));
}
} catch (batchException) {
// this allows us to catch and debug any errors in the batch handling
throw batchException;
}
return __return;
}