Sdílet prostřednictvím


Offers class

Slouží k dotazování nebo čtení všech nabídek.

Pokud chcete přečíst nebo nahradit existující nabídku ID, přečtěte si nabídky.

Vlastnosti

client

Metody

query(SqlQuerySpec, FeedOptions)

Zadejte dotaz na všechny nabídky.

příklad

Přečtěte si nabídku pro konkrétní ID.

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)

Zadejte dotaz na všechny nabídky.

readAll(FeedOptions)

Přečtěte si všechny nabídky.

příklad

Čtení všech nabídek do pole

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();

Podrobnosti vlastnosti

client

client: CosmosClient

Hodnota vlastnosti

Podrobnosti metody

query(SqlQuerySpec, FeedOptions)

Zadejte dotaz na všechny nabídky.

příklad

Přečtěte si nabídku pro konkrétní ID.

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>

Parametry

query
SqlQuerySpec

Konfigurace dotazu pro operaci. Další informace o konfiguraci dotazu najdete v tématu sqlQuerySpec.

options
FeedOptions

Návraty

query<T>(SqlQuerySpec, FeedOptions)

Zadejte dotaz na všechny nabídky.

function query<T>(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<T>

Parametry

query
SqlQuerySpec

Konfigurace dotazu pro operaci. Další informace o konfiguraci dotazu najdete v tématu sqlQuerySpec.

options
FeedOptions

Návraty

readAll(FeedOptions)

Přečtěte si všechny nabídky.

příklad

Čtení všech nabídek do pole

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>

Parametry

options
FeedOptions

Návraty