StoredProcedure class
ID별로 특정 기존 저장 프로시저를 읽거나, 대체하거나, 삭제하거나, 실행하기 위한 작업입니다.
저장 프로시저를 만들거나, 모두 읽거나, 쿼리하는 작업의 경우
메서드
| delete(Request |
지정된 StoredProcedure삭제합니다. 예시
|
| execute<T>(Partition |
지정된 StoredProcedure실행합니다. 지정된 형식 T는 클라이언트에 의해 적용되지 않습니다. 입력한 T 형식과 일치하는 저장 프로시저의 응답에 대한 유효성을 검사해야 합니다. 예시
|
| read(Request |
지정된 StoredProcedure대한 StoredProcedureDefinition 읽습니다. 예시
|
| replace(Stored |
지정된 StoredProcedure 지정된 StoredProcedureDefinition바꿉다. 예시
|
속성 세부 정보
container
id
id: string
속성 값
string
url
리소스에 대한 참조 URL을 반환합니다. 사용 권한에서 연결에 사용됩니다.
string url
속성 값
string
메서드 세부 정보
delete(RequestOptions)
지정된 StoredProcedure삭제합니다.
예시
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" });
await container.scripts.storedProcedure("<sproc-id>").delete();
function delete(options?: RequestOptions): Promise<StoredProcedureResponse>
매개 변수
- options
- RequestOptions
반환
Promise<StoredProcedureResponse>
execute<T>(PartitionKey, any[], RequestOptions)
지정된 StoredProcedure실행합니다.
지정된 형식 T는 클라이언트에 의해 적용되지 않습니다. 입력한 T 형식과 일치하는 저장 프로시저의 응답에 대한 유효성을 검사해야 합니다.
예시
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 { resource: result } = await container.scripts
.storedProcedure("<sproc-id>")
.execute(undefined);
function execute<T>(partitionKey: PartitionKey, params?: any[], options?: RequestOptions): Promise<ResourceResponse<T>>
매개 변수
- partitionKey
- PartitionKey
저장 프로시저를 실행할 때 사용할 파티션 키
- params
-
any[]
지정된 StoredProcedure인수로 전달할 매개 변수 배열입니다.
- options
- RequestOptions
StoredProcedure 호출하는 파티션 키와 같은 추가 옵션입니다. *
반환
Promise<ResourceResponse<T>>
read(RequestOptions)
지정된 StoredProcedure대한 StoredProcedureDefinition 읽습니다.
예시
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 { resource: sproc } = await container.scripts.storedProcedure("<sproc-id>").read();
function read(options?: RequestOptions): Promise<StoredProcedureResponse>
매개 변수
- options
- RequestOptions
반환
Promise<StoredProcedureResponse>
replace(StoredProcedureDefinition, RequestOptions)
지정된 StoredProcedure 지정된 StoredProcedureDefinition바꿉다.
예시
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);
sproc.body = function () {
const x = 20;
console.log(x);
};
const { resource: replacedSproc } = await container.scripts
.storedProcedure(sproc.id)
.replace(sproc);
function replace(body: StoredProcedureDefinition, options?: RequestOptions): Promise<StoredProcedureResponse>
매개 변수
지정한 StoredProcedureDefinition 기존 정의를 대체합니다.
- options
- RequestOptions
반환
Promise<StoredProcedureResponse>