你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Offers class

用于查询或读取所有产品/服务。

请参阅 产品/服务,以按 ID 读取或替换现有的 产品/服务

属性

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();
query<T>(SqlQuerySpec, 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();

属性详细信息

client

client: CosmosClient

属性值

方法详细信息

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

返回

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

返回