TableClient class

TableClient는 단일 테이블에서 작업을 수행할 수 있는 Azure Tables 서비스에 대한 클라이언트를 나타냅니다.

생성자

TableClient(string, string, NamedKeyCredential, TableServiceClientOptions)

TableClient 클래스의 새 인스턴스를 만듭니다.

TableClient(string, string, SASCredential, TableServiceClientOptions)

TableClient 클래스의 새 인스턴스를 만듭니다.

TableClient(string, string, TableServiceClientOptions)

TableClient의 인스턴스를 만듭니다.

TableClient(string, string, TokenCredential, TableServiceClientOptions)

TableClient 클래스의 새 인스턴스를 만듭니다.

속성

pipeline

URL에 대한 HTTP 요청을 만들기 위한 파이프라인을 나타냅니다. 파이프라인에는 서버에 대해 각 요청을 조작하기 전과 후에 각 요청을 조작하는 여러 정책이 있을 수 있습니다.

tableName

작업을 수행할 테이블의 이름입니다.

url

테이블 계정 URL

메서드

createEntity<T>(TableEntity<T>, OperationOptions)

테이블에 엔터티를 삽입합니다.

createTable(OperationOptions)

tableName이 클라이언트 생성자에 전달된 테이블을 만듭니다.

deleteEntity(string, string, DeleteTableEntityOptions)

테이블에서 지정된 엔터티를 삭제합니다.

deleteTable(OperationOptions)

모든 엔터티를 사용하여 현재 테이블을 영구적으로 삭제합니다.

fromConnectionString(string, string, TableServiceClientOptions)

연결 문자열에서 TableClient의 인스턴스를 만듭니다.

getAccessPolicy(OperationOptions)

공유 액세스 서명과 함께 사용할 수 있는 테이블에 지정된 저장된 액세스 정책에 대한 세부 정보를 검색합니다.

getEntity<T>(string, string, GetTableEntityOptions)

테이블의 단일 엔터티를 반환합니다.

listEntities<T>(ListTableEntitiesOptions)

테이블의 엔터티를 쿼리합니다.

setAccessPolicy(SignedIdentifier[], OperationOptions)

공유 액세스 서명과 함께 사용할 수 있는 테이블에 대해 저장된 액세스 정책을 설정합니다.

submitTransaction(TransactionAction[])

작업 집합으로 구성된 트랜잭션을 제출합니다. 작업을 목록으로 제공하거나 TableTransaction을 사용하여 트랜잭션을 빌드할 수 있습니다.

예제 사용법:

const { TableClient } = require("@azure/data-tables");
const connectionString = "<connection-string>"
const tableName = "<tableName>"
const client = TableClient.fromConnectionString(connectionString, tableName);
const actions = [
   ["create", {partitionKey: "p1", rowKey: "1", data: "test1"}],
   ["delete", {partitionKey: "p1", rowKey: "2"}],
   ["update", {partitionKey: "p1", rowKey: "3", data: "newTest"}, "Merge"]
]
const result = await client.submitTransaction(actions);

TableTransaction 사용 예:

const { TableClient } = require("@azure/data-tables");
const connectionString = "<connection-string>"
const tableName = "<tableName>"
const client = TableClient.fromConnectionString(connectionString, tableName);
const transaction = new TableTransaction();
// Call the available action in the TableTransaction object
transaction.create({partitionKey: "p1", rowKey: "1", data: "test1"});
transaction.delete("p1", "2");
transaction.update({partitionKey: "p1", rowKey: "3", data: "newTest"}, "Merge")
// submitTransaction with the actions list on the transaction.
const result = await client.submitTransaction(transaction.actions);
updateEntity<T>(TableEntity<T>, UpdateMode, UpdateTableEntityOptions)

테이블의 엔터티를 업데이트합니다.

upsertEntity<T>(TableEntity<T>, UpdateMode, OperationOptions)

테이블의 엔터티를 Upsert합니다.

생성자 세부 정보

TableClient(string, string, NamedKeyCredential, TableServiceClientOptions)

TableClient 클래스의 새 인스턴스를 만듭니다.

new TableClient(url: string, tableName: string, credential: NamedKeyCredential, options?: TableServiceClientOptions)

매개 변수

url

string

원하는 작업의 대상인 서비스 계정의 URL(예: "https://myaccount.table.core.windows.net")입니다.

tableName

string

테이블의 이름

credential
NamedKeyCredential

요청을 인증하는 데 사용되는 NamedKeyCredential입니다. 노드에 대해서만 지원됨

options
TableServiceClientOptions

(선택 사항) HTTP 파이프라인을 구성하는 옵션입니다.

계정 이름/키를 사용하는 예제:

const { AzureNamedKeyCredential, TableClient } = require("@azure/data-tables");
const account = "<storage account name>";
const accountKey = "<account key>"
const tableName = "<table name>";
const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);

const client = new TableClient(
  `https://${account}.table.core.windows.net`,
  tableName,
  sharedKeyCredential
);

TableClient(string, string, SASCredential, TableServiceClientOptions)

TableClient 클래스의 새 인스턴스를 만듭니다.

new TableClient(url: string, tableName: string, credential: SASCredential, options?: TableServiceClientOptions)

매개 변수

url

string

원하는 작업의 대상인 서비스 계정의 URL(예: "https://myaccount.table.core.windows.net")입니다.

tableName

string

테이블의 이름

credential
SASCredential

요청을 인증하는 데 사용되는 SASCredential

options
TableServiceClientOptions

(선택 사항) HTTP 파이프라인을 구성하는 옵션입니다.

SAS 토큰을 사용하는 예제:

const { AzureSASCredential, TableClient } = require("@azure/data-tables");
const account = "<storage account name>";
const sasToken = "<sas-token>";
const tableName = "<table name>";
const sasCredential = new AzureSASCredential(sasToken);

const client = new TableClient(
  `https://${account}.table.core.windows.net`,
  tableName,
  sasCredential
);

TableClient(string, string, TableServiceClientOptions)

TableClient의 인스턴스를 만듭니다.

new TableClient(url: string, tableName: string, options?: TableServiceClientOptions)

매개 변수

url

string

Azure Storage 테이블 서비스를 가리키는 클라이언트 문자열(예: "https://myaccount.table.core.windows.net") SAS(예: "https://myaccount.table.core.windows.net?sasString")를 추가할 수 있습니다.

tableName

string

테이블의 이름

options
TableServiceClientOptions

HTTP 파이프라인을 구성하는 옵션입니다.

SAS 토큰을 추가하는 예제:

const { TableClient } = require("@azure/data-tables");
const account = "<storage account name>";
const sasToken = "<SAS token>";
const tableName = "<table name>";

const client = new TableClient(
  `https://${account}.table.core.windows.net?${sasToken}`,
  `${tableName}`
);

TableClient(string, string, TokenCredential, TableServiceClientOptions)

TableClient 클래스의 새 인스턴스를 만듭니다.

new TableClient(url: string, tableName: string, credential: TokenCredential, options?: TableServiceClientOptions)

매개 변수

url

string

원하는 작업의 대상인 서비스 계정의 URL(예: "https://myaccount.table.core.windows.net")입니다.

tableName

string

테이블의 이름

credential
TokenCredential

요청을 인증하는 데 사용되는 Azure Active Directory 자격 증명

options
TableServiceClientOptions

(선택 사항) HTTP 파이프라인을 구성하는 옵션입니다.

Azure Active Directory 자격 증명을 사용하는 예제:

cons { DefaultAzureCredential } = require("@azure/identity");
const { AzureSASCredential, TableClient } = require("@azure/data-tables");
const account = "<storage account name>";
const sasToken = "<sas-token>";
const tableName = "<table name>";
const credential = new DefaultAzureCredential();

const client = new TableClient(
  `https://${account}.table.core.windows.net`,
  tableName,
  credential
);

속성 세부 정보

pipeline

URL에 대한 HTTP 요청을 만들기 위한 파이프라인을 나타냅니다. 파이프라인에는 서버에 대해 각 요청을 조작하기 전과 후에 각 요청을 조작하는 여러 정책이 있을 수 있습니다.

pipeline: Pipeline

속성 값

tableName

작업을 수행할 테이블의 이름입니다.

tableName: string

속성 값

string

url

테이블 계정 URL

url: string

속성 값

string

메서드 세부 정보

createEntity<T>(TableEntity<T>, OperationOptions)

테이블에 엔터티를 삽입합니다.

function createEntity<T>(entity: TableEntity<T>, options?: OperationOptions): Promise<TableInsertEntityHeaders>

매개 변수

entity

TableEntity<T>

테이블 엔터티의 속성입니다.

options
OperationOptions

옵션 매개 변수입니다.

엔터티 만들기 예제

const { AzureNamedKeyCredential, TableClient } = require("@azure/data-tables")
const account = "<storage account name>";
const accountKey = "<account key>"
const tableName = "<table name>";
const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);

const client = new TableClient(
  `https://${account}.table.core.windows.net`,
  `${tableName}`,
  sharedKeyCredential
);

// partitionKey and rowKey are required properties of the entity to create
// and accepts any other properties
await client.createEntity({partitionKey: "p1", rowKey: "r1", foo: "Hello!"});

반환

createTable(OperationOptions)

tableName이 클라이언트 생성자에 전달된 테이블을 만듭니다.

function createTable(options?: OperationOptions): Promise<void>

매개 변수

options
OperationOptions

옵션 매개 변수입니다.

테이블 만들기 예제

const { AzureNamedKeyCredential, TableClient } = require("@azure/data-tables")
const account = "<storage account name>";
const accountKey = "<account key>"
const tableName = "<table name>";
const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);

const client = new TableClient(
  `https://${account}.table.core.windows.net`,
  `${tableName}`,
  sharedKeyCredential
);

// calling create table will create the table used
// to instantiate the TableClient.
// Note: If the table already
// exists this function doesn't throw.
await client.createTable();

반환

Promise<void>

deleteEntity(string, string, DeleteTableEntityOptions)

테이블에서 지정된 엔터티를 삭제합니다.

function deleteEntity(partitionKey: string, rowKey: string, options?: DeleteTableEntityOptions): Promise<TableDeleteEntityHeaders>

매개 변수

partitionKey

string

엔터티의 파티션 키입니다.

rowKey

string

엔터티의 행 키입니다.

options
DeleteTableEntityOptions

옵션 매개 변수입니다.

엔터티 삭제 예제

const { AzureNamedKeyCredential, TableClient } = require("@azure/data-tables")
const account = "<storage account name>";
const accountKey = "<account key>"
const tableName = "<table name>";
const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);

const client = new TableClient(
  `https://${account}.table.core.windows.net`,
  `${tableName}`,
  sharedKeyCredential
);

// deleteEntity deletes the entity that matches
// exactly the partitionKey and rowKey passed as parameters
await client.deleteEntity("<partitionKey>", "<rowKey>")

반환

deleteTable(OperationOptions)

모든 엔터티를 사용하여 현재 테이블을 영구적으로 삭제합니다.

function deleteTable(options?: OperationOptions): Promise<void>

매개 변수

options
OperationOptions

옵션 매개 변수입니다.

테이블 삭제 예제

const { AzureNamedKeyCredential, TableClient } = require("@azure/data-tables")
const account = "<storage account name>";
const accountKey = "<account key>"
const tableName = "<table name>";
const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);

const client = new TableClient(
  `https://${account}.table.core.windows.net`,
  `${tableName}`,
  sharedKeyCredential
);

// calling deleteTable will delete the table used
// to instantiate the TableClient.
// Note: If the table doesn't exist this function doesn't fail.
await client.deleteTable();

반환

Promise<void>

fromConnectionString(string, string, TableServiceClientOptions)

연결 문자열에서 TableClient의 인스턴스를 만듭니다.

static function fromConnectionString(connectionString: string, tableName: string, options?: TableServiceClientOptions): TableClient

매개 변수

connectionString

string

계정 연결 문자열 또는 Azure Storage 계정의 SAS 연결 문자열입니다. [ 참고 - 계정 연결 문자열은 NODE.JS 런타임에서만 사용할 수 있습니다. ] 계정 연결 문자열 예제 -DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net SAS 연결 문자열 예제 - BlobEndpoint=https://myaccount.table.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString

tableName

string

options
TableServiceClientOptions

HTTP 파이프라인을 구성하는 옵션입니다.

반환

지정된 연결 문자열의 새 TableClient입니다.

getAccessPolicy(OperationOptions)

공유 액세스 서명과 함께 사용할 수 있는 테이블에 지정된 저장된 액세스 정책에 대한 세부 정보를 검색합니다.

function getAccessPolicy(options?: OperationOptions): Promise<GetAccessPolicyResponse>

매개 변수

options
OperationOptions

옵션 매개 변수입니다.

반환

getEntity<T>(string, string, GetTableEntityOptions)

테이블의 단일 엔터티를 반환합니다.

function getEntity<T>(partitionKey: string, rowKey: string, options?: GetTableEntityOptions): Promise<GetTableEntityResponse<TableEntityResult<T>>>

매개 변수

partitionKey

string

엔터티의 파티션 키입니다.

rowKey

string

엔터티의 행 키입니다.

options
GetTableEntityOptions

옵션 매개 변수입니다.

엔터티 가져오기 예제

const { AzureNamedKeyCredential, TableClient } = require("@azure/data-tables")
const account = "<storage account name>";
const accountKey = "<account key>"
const tableName = "<table name>";
const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);

const client = new TableClient(
  `https://${account}.table.core.windows.net`,
  `${tableName}`,
  sharedKeyCredential
);

// getEntity will get a single entity stored in the service that
// matches exactly the partitionKey and rowKey used as parameters
// to the method.
const entity = await client.getEntity("<partitionKey>", "<rowKey>");
console.log(entity);

반환

listEntities<T>(ListTableEntitiesOptions)

테이블의 엔터티를 쿼리합니다.

function listEntities<T>(options?: ListTableEntitiesOptions): PagedAsyncIterableIterator<TableEntityResult<T>, TableEntityResultPage<T>, PageSettings>

매개 변수

options
ListTableEntitiesOptions

옵션 매개 변수입니다.

엔터티 나열 예제

const { AzureNamedKeyCredential, TableClient } = require("@azure/data-tables")
const account = "<storage account name>";
const accountKey = "<account key>"
const tableName = "<table name>";
const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);

const client = new TableClient(
  `https://${account}.table.core.windows.net`,
  `${tableName}`,
  sharedKeyCredential
);

// list entities returns a AsyncIterableIterator
// this helps consuming paginated responses by
// automatically handling getting the next pages
const entities = client.listEntities();

// this loop will get all the entities from all the pages
// returned by the service
for await (const entity of entities) {
   console.log(entity);
}

반환

setAccessPolicy(SignedIdentifier[], OperationOptions)

공유 액세스 서명과 함께 사용할 수 있는 테이블에 대해 저장된 액세스 정책을 설정합니다.

function setAccessPolicy(tableAcl: SignedIdentifier[], options?: OperationOptions): Promise<TableSetAccessPolicyHeaders>

매개 변수

tableAcl

SignedIdentifier[]

테이블의 Access Control 목록입니다.

options
OperationOptions

옵션 매개 변수입니다.

반환

submitTransaction(TransactionAction[])

작업 집합으로 구성된 트랜잭션을 제출합니다. 작업을 목록으로 제공하거나 TableTransaction을 사용하여 트랜잭션을 빌드할 수 있습니다.

예제 사용법:

const { TableClient } = require("@azure/data-tables");
const connectionString = "<connection-string>"
const tableName = "<tableName>"
const client = TableClient.fromConnectionString(connectionString, tableName);
const actions = [
   ["create", {partitionKey: "p1", rowKey: "1", data: "test1"}],
   ["delete", {partitionKey: "p1", rowKey: "2"}],
   ["update", {partitionKey: "p1", rowKey: "3", data: "newTest"}, "Merge"]
]
const result = await client.submitTransaction(actions);

TableTransaction 사용 예:

const { TableClient } = require("@azure/data-tables");
const connectionString = "<connection-string>"
const tableName = "<tableName>"
const client = TableClient.fromConnectionString(connectionString, tableName);
const transaction = new TableTransaction();
// Call the available action in the TableTransaction object
transaction.create({partitionKey: "p1", rowKey: "1", data: "test1"});
transaction.delete("p1", "2");
transaction.update({partitionKey: "p1", rowKey: "3", data: "newTest"}, "Merge")
// submitTransaction with the actions list on the transaction.
const result = await client.submitTransaction(transaction.actions);
function submitTransaction(actions: TransactionAction[]): Promise<TableTransactionResponse>

매개 변수

actions

TransactionAction[]

수행할 작업과 작업을 수행할 엔터티가 포함된 튜플

반환

updateEntity<T>(TableEntity<T>, UpdateMode, UpdateTableEntityOptions)

테이블의 엔터티를 업데이트합니다.

function updateEntity<T>(entity: TableEntity<T>, mode?: UpdateMode, options?: UpdateTableEntityOptions): Promise<TableUpdateEntityHeaders>

매개 변수

entity

TableEntity<T>

업데이트할 엔터티의 속성입니다.

mode
UpdateMode

엔터티를 업데이트하는 다양한 모드: - 병합: 기존 엔터티를 대체하지 않고 엔터티의 속성을 업데이트하여 엔터티를 업데이트. - 바꾸기: 전체 엔터티를 바꿔 기존 엔터티를 업데이트.

options
UpdateTableEntityOptions

옵션 매개 변수입니다.

엔터티 업데이트 예제

const { AzureNamedKeyCredential, TableClient } = require("@azure/data-tables")
const account = "<storage account name>";
const accountKey = "<account key>"
const tableName = "<table name>";
const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);

const client = new TableClient(
  `https://${account}.table.core.windows.net`,
  `${tableName}`,
  sharedKeyCredential
);

const entity = {partitionKey: "p1", rowKey: "r1", bar: "updatedBar"};

// Update uses update mode "Merge" as default
// merge means that update will match a stored entity
// that has the same partitionKey and rowKey as the entity
// passed to the method and then will only update the properties present in it.
// Any other properties that are not defined in the entity passed to updateEntity
// will remain as they are in the service
await client.updateEntity(entity)

// We can also set the update mode to Replace, which will match the entity passed
// to updateEntity with one stored in the service and replace with the new one.
// If there are any missing properties in the entity passed to updateEntity, they
// will be removed from the entity stored in the service
await client.updateEntity(entity, "Replace")

반환

upsertEntity<T>(TableEntity<T>, UpdateMode, OperationOptions)

테이블의 엔터티를 Upsert합니다.

function upsertEntity<T>(entity: TableEntity<T>, mode?: UpdateMode, options?: OperationOptions): Promise<TableMergeEntityHeaders>

매개 변수

entity

TableEntity<T>

테이블 엔터티의 속성입니다.

mode
UpdateMode

엔터티를 업데이트하는 다양한 모드: - 병합: 기존 엔터티를 대체하지 않고 엔터티의 속성을 업데이트하여 엔터티를 업데이트. - 바꾸기: 전체 엔터티를 바꿔 기존 엔터티를 업데이트.

options
OperationOptions

옵션 매개 변수입니다.

엔터티를 upsert하는 예제

const { AzureNamedKeyCredential, TableClient } = require("@azure/data-tables")
const account = "<storage account name>";
const accountKey = "<account key>"
const tableName = "<table name>";
const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey);

const client = new TableClient(
  `https://${account}.table.core.windows.net`,
  `${tableName}`,
  sharedKeyCredential
);

const entity = {partitionKey: "p1", rowKey: "r1", bar: "updatedBar"};

// Upsert uses update mode "Merge" as default.
// This behaves similarly to update but creates the entity
// if it doesn't exist in the service
await client.upsertEntity(entity)

// We can also set the update mode to Replace.
// This behaves similarly to update but creates the entity
// if it doesn't exist in the service
await client.upsertEntity(entity, "Replace")

반환