-
-
Save johndowns/5e1b29d415c1f9ad9a5e6a53a6691d66 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var query: IParameterizedQuery = { | |
query: "SELECT VALUE udf.getCustomerId(c) FROM c WHERE c.type = \'order\' AND ARRAY_CONTAINS(c.items, { productId: @productId }, true)", | |
parameters: [ | |
{ name: "@productId", value: productId } | |
] | |
}; | |
var queryCallbackFunction = (error: IFeedCallbackError, results: string[], options: IFeedCallbackOptions) => { | |
if (error) { | |
// the query was accepted and processed, but something went wrong | |
throw new Error("Error in query callback: " + error.body); | |
} | |
// we successfully received the customer IDs, so we can add them to the output array | |
outputArray.push({ | |
productId: productId, | |
customerIds: results | |
}); | |
} | |
var queryAccepted = collection.queryDocuments<string>(collection.getSelfLink(), query, queryCallbackFunction); | |
if (! queryAccepted) { | |
// the query wasn't accepted - this is likely because our stored procedure is running out of time in which to execute | |
throw new Error("Query was not accepted for product ID " + productId); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment