StoredProcedures class
모든 저장 프로시저를 생성, 업서팅 또는 읽기/쿼리하기 위한 작업입니다.
ID별로 특정 기존 저장 프로시저를 읽거나 바꾸거나 삭제하거나 실행하는 작업은 container.storedProcedure()
참조하세요.
속성
container |
메서드
create(Stored |
StoredProcedure를 만듭니다. Azure Cosmos DB를 사용하면 저장 프로시저를 스토리지 계층에서 항목 컨테이너에 대해 직접 실행할 수 있습니다. 지정된 컨테이너의 기본 스토리지 파티션에 있는 ACID 트랜잭션에서 스크립트가 실행됩니다. 자세한 내용은 서버 쪽 JavaScript API 설명서를 참조하세요. 예제
|
query(Sql |
모든 저장 프로시저를 쿼리합니다. 예제 배열에 대한 모든 저장 프로시저를 읽습니다.
|
query<T>(Sql |
모든 저장 프로시저를 쿼리합니다. 예제 배열에 대한 모든 저장 프로시저를 읽습니다.
|
read |
모든 저장 프로시저를 읽습니다. 예제 배열에 대한 모든 저장 프로시저를 읽습니다.
|
속성 세부 정보
container
메서드 세부 정보
create(StoredProcedureDefinition, RequestOptions)
StoredProcedure를 만듭니다.
Azure Cosmos DB를 사용하면 저장 프로시저를 스토리지 계층에서 항목 컨테이너에 대해 직접 실행할 수 있습니다. 지정된 컨테이너의 기본 스토리지 파티션에 있는 ACID 트랜잭션에서 스크립트가 실행됩니다. 자세한 내용은 서버 쪽 JavaScript API 설명서를 참조하세요.
예제
import { CosmosClient, StoredProcedureDefinition } from "@azure/cosmos";
const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const { database } = await client.databases.createIfNotExists({ id: "Test Database" });
const { container } = await database.containers.createIfNotExists({ id: "Test Container" });
const sprocDefinition: StoredProcedureDefinition = {
id: "sample sproc",
body: "function () { const x = 10; }",
};
const { resource: sproc } = await container.scripts.storedProcedures.create(sprocDefinition);
function create(body: StoredProcedureDefinition, options?: RequestOptions): Promise<StoredProcedureResponse>
매개 변수
- options
- RequestOptions
반환
Promise<StoredProcedureResponse>
query(SqlQuerySpec, FeedOptions)
모든 저장 프로시저를 쿼리합니다.
예제
배열에 대한 모든 저장 프로시저를 읽습니다.
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 { database } = await client.databases.createIfNotExists({ id: "Test Database" });
const { container } = await database.containers.createIfNotExists({ id: "Test Container" });
const querySpec: SqlQuerySpec = {
query: `SELECT * FROM root r WHERE r.id = @sproc`,
parameters: [{ name: "@sproc", value: "Todo" }],
};
const { resources: storedProceduresList } = await container.scripts.storedProcedures
.query(querySpec)
.fetchAll();
function query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>
매개 변수
- query
- SqlQuerySpec
작업에 대한 쿼리 구성입니다. 쿼리를 구성하는 방법에 대한 자세한 내용은 SqlQuerySpec 참조하세요.
- options
- FeedOptions
반환
QueryIterator<any>
query<T>(SqlQuerySpec, FeedOptions)
모든 저장 프로시저를 쿼리합니다.
예제
배열에 대한 모든 저장 프로시저를 읽습니다.
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 { database } = await client.databases.createIfNotExists({ id: "Test Database" });
const { container } = await database.containers.createIfNotExists({ id: "Test Container" });
const querySpec: SqlQuerySpec = {
query: `SELECT * FROM root r WHERE r.id = @sproc`,
parameters: [{ name: "@sproc", value: "Todo" }],
};
const { resources: storedProceduresList } = await container.scripts.storedProcedures
.query(querySpec)
.fetchAll();
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 { database } = await client.databases.createIfNotExists({ id: "Test Database" });
const { container } = await database.containers.createIfNotExists({ id: "Test Container" });
const { resources: storedProceduresList } = await container.scripts.storedProcedures
.readAll()
.fetchAll();
function readAll(options?: FeedOptions): QueryIterator<StoredProcedureDefinition & Resource>
매개 변수
- options
- FeedOptions