【发布时间】:2021-11-02 21:02:07
【问题描述】:
我有一些润滑油。润滑油可能有货,也可能缺货。我想一次最多查询 5 个润滑油。
当我不使用过滤器时,会返回继续令牌并正常工作。
// <Get all lubes / first page (max: 5) >
async getAll(token?: string, limit = 5) {
if (!token) this.store.lube.removeAll();
const {
resources: items,
continuationToken,
hasMoreResults,
} = await this.dbContainer.items
.readAll<ILube>({
maxItemCount: limit,
continuationToken: token,
// partitionKey: "HFO",
})
.fetchNext();
this.store.lube.load(items);
return { hasMoreResults, continuationToken };
}
但是,当我想使用 WHERE 按可用润滑油或缺货进行过滤时,会返回继续令牌,但是,当我检索数据时,它不会t 工作 - 没有错误。
// <Get by availability status>
async getByAvailability(availability: boolean, token?: string, limit = 5) {
if (!token) this.store.lube.removeAll();
this.store.lube.removeAll();
const querySpec = {
query: "SELECT * FROM c WHERE c.isAvailable = @availability",
parameters: [
{
name: "@availability",
value: availability,
},
],
};
const {
resources: items,
continuationToken,
hasMoreResults,
} = await this.dbContainer.items
.query<ILube>(querySpec, { maxItemCount: limit })
.fetchNext();
this.store.lube.load(items);
return { hasMoreResults, continuationToken };
}
底线,我如何将continuation token 与where 一起使用?
【问题讨论】:
-
请在 Twitter 上查看此主题:twitter.com/gmantri/status/1434551588966731791。 HTH。
标签: azure azure-cosmosdb azure-cosmosdb-sqlapi