Offers class
属性
client |
方法
query(Sql |
查询所有产品/服务。 示例 读取特定 ID 的 offer。
|
query<T>(Sql |
查询所有产品/服务。 |
read |
读取所有产品/服务。 示例 读取数组的所有产品/服务。
|
属性详细信息
client
方法详细信息
query(SqlQuerySpec, FeedOptions)
查询所有产品/服务。
示例
读取特定 ID 的 offer。
import { CosmosClient, SqlQuerySpec } from "@azure/cosmos";
const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const querySpec: SqlQuerySpec = {
query: `SELECT * FROM root r WHERE r.id = @offer`,
parameters: [{ name: "@offer", value: "<offer-id>" }],
};
const { resources: offer } = await client.offers.query(querySpec).fetchAll();
function query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>
参数
- query
- SqlQuerySpec
作的查询配置。 有关如何配置查询的详细信息,请参阅 SqlQuerySpec。
- options
- FeedOptions
返回
QueryIterator<any>
query<T>(SqlQuerySpec, FeedOptions)
查询所有产品/服务。
function query<T>(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<T>
参数
- query
- SqlQuerySpec
作的查询配置。 有关如何配置查询的详细信息,请参阅 SqlQuerySpec。
- options
- FeedOptions
返回
readAll(FeedOptions)
读取所有产品/服务。
示例
读取数组的所有产品/服务。
import { CosmosClient } from "@azure/cosmos";
const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const { resources: offerList } = await client.offers.readAll().fetchAll();
function readAll(options?: FeedOptions): QueryIterator<OfferDefinition & Resource>
参数
- options
- FeedOptions