Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
readItems(req, res, "Documents", async ({ continuation, maxItemCount }) => {
const body = await json(req);
if (!body.query) {
res.statusCode = 400;
return { Message: "missing query" };
}
const collection = account.database(dbId).collection(collId);
if (req.headers["x-ms-documentdb-query-enablecrosspartition"] !== "true") {
const { partitionKey }: { partitionKey?: any } = collection.read() || {};
const paths = (partitionKey || {}).paths || [];
if (paths.length && !query(body.query).containsPartitionKeys(paths)) {
res.statusCode = 400;
return { Message: "missing partition keys" };
}
}
return collection.documents.query(body, { continuation, maxItemCount });
});
read({
maxItemCount,
continuation
}: {
maxItemCount?: number | null;
continuation?: {
token: string;
} | null;
} = {}) {
if (!this._parent.read()) return null;
const data = [...this._data.values()].map(item => item.read());
return query("SELECT * FROM c").exec(data, { maxItemCount, continuation });
}
},
{
maxItemCount,
continuation
}: {
maxItemCount?: number | null;
continuation?: {
token: string;
} | null;
}
) {
if (!this._parent.read()) return null;
const data = [...this._data.values()].map(item => item.read());
const udf = this._userDefinedFunctions();
return query(params.query).exec(data, {
parameters: params.parameters,
udf,
maxItemCount,
continuation
});
}