Share via


TableClient class

TableClient, tek bir tabloda işlem gerçekleştirmenize olanak sağlayan Azure Tablolar hizmetine yönelik bir İstemciyi temsil eder.

Oluşturucular

TableClient(string, string, NamedKeyCredential, TableServiceClientOptions)

TableClient sınıfının yeni bir örneğini oluşturur.

TableClient(string, string, SASCredential, TableServiceClientOptions)

TableClient sınıfının yeni bir örneğini oluşturur.

TableClient(string, string, TableServiceClientOptions)

TableClient örneğini oluşturur.

TableClient(string, string, TokenCredential, TableServiceClientOptions)

TableClient sınıfının yeni bir örneğini oluşturur.

Özellikler

pipeline

URL'ye HTTP isteği göndermek için bir işlem hattını temsil eder. İşlem hatları, her isteğin sunucuya yapılmadan önce ve sonra yönetilmesini yönetmek için birden çok ilkeye sahip olabilir.

tableName

üzerinde işlem gerçekleştirilecek tablonun adı.

url

Tablo Hesabı URL'si

Yöntemler

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

Tabloya varlık ekleyin.

createTable(OperationOptions)

tableName değeri istemci oluşturucuya geçirilirken bir tablo oluşturur

deleteEntity(string, string, DeleteTableEntityOptions)

Tabloda belirtilen varlığı siler.

deleteTable(OperationOptions)

Geçerli tabloyu tüm varlıklarıyla birlikte kalıcı olarak siler.

fromConnectionString(string, string, TableServiceClientOptions)

Bağlantı dizesinden bir TableClient örneği oluşturur.

getAccessPolicy(OperationOptions)

Tabloda belirtilen ve Paylaşılan Erişim İmzaları ile kullanılabilecek tüm depolanmış erişim ilkeleriyle ilgili ayrıntıları alır.

getEntity<T>(string, string, GetTableEntityOptions)

Tabloda tek bir varlık döndürür.

listEntities<T>(ListTableEntitiesOptions)

Tablodaki varlıkları sorgular.

setAccessPolicy(SignedIdentifier[], OperationOptions)

Paylaşılan Erişim İmzaları ile kullanılabilecek tablo için depolanan erişim ilkelerini ayarlar.

submitTransaction(TransactionAction[])

Bir dizi eylemden oluşan bir İşlem gönderir. Eylemleri liste olarak sağlayabilir veya işlemi oluşturmaya yardımcı olması için TableTransaction'ı kullanabilirsiniz.

Örnek kullanım:

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 ile örnek kullanım:

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)

Tablodaki bir varlığı güncelleştirin.

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

Tabloya bir varlık ekleyin.

Oluşturucu Ayrıntıları

TableClient(string, string, NamedKeyCredential, TableServiceClientOptions)

TableClient sınıfının yeni bir örneğini oluşturur.

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

Parametreler

url

string

İstenen işlemin hedefi olan hizmet hesabının URL'si, örneğin "https://myaccount.table.core.windows.net".

tableName

string

tablonun adı

credential
NamedKeyCredential

İsteklerin kimliğini doğrulamak için kullanılan NamedKeyCredential. Yalnızca Düğüm için Desteklenir

options
TableServiceClientOptions

İsteğe bağlı. HTTP işlem hattını yapılandırma seçenekleri.

Hesap adı/anahtarı kullanan örnek:

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 sınıfının yeni bir örneğini oluşturur.

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

Parametreler

url

string

İstenen işlemin hedefi olan hizmet hesabının URL'si, örneğin "https://myaccount.table.core.windows.net".

tableName

string

tablonun adı

credential
SASCredential

İsteklerin kimliğini doğrulamak için kullanılan SASCredential

options
TableServiceClientOptions

İsteğe bağlı. HTTP işlem hattını yapılandırma seçenekleri.

SAS Belirteci kullanma örneği:

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 örneğini oluşturur.

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

Parametreler

url

string

"https://myaccount.table.core.windows.net" gibi Azure Depolama tablo hizmetine işaret eden bir İstemci dizesi. "https://myaccount.table.core.windows.net?sasString" gibi bir SAS ekleyebilirsiniz.

tableName

string

tablonun adı

options
TableServiceClientOptions

HTTP işlem hattını yapılandırma seçenekleri.

SAS belirtecini ekleme örneği:

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 sınıfının yeni bir örneğini oluşturur.

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

Parametreler

url

string

İstenen işlemin hedefi olan hizmet hesabının URL'si, örneğin "https://myaccount.table.core.windows.net".

tableName

string

tablonun adı

credential
TokenCredential

İsteklerin kimliğini doğrulamak için kullanılan Azure Active Directory kimlik bilgileri

options
TableServiceClientOptions

İsteğe bağlı. HTTP işlem hattını yapılandırma seçenekleri.

Azure Active Directory kimlik bilgilerini kullanma örneği:

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

Özellik Ayrıntıları

pipeline

URL'ye HTTP isteği göndermek için bir işlem hattını temsil eder. İşlem hatları, her isteğin sunucuya yapılmadan önce ve sonra yönetilmesini yönetmek için birden çok ilkeye sahip olabilir.

pipeline: Pipeline

Özellik Değeri

tableName

üzerinde işlem gerçekleştirilecek tablonun adı.

tableName: string

Özellik Değeri

string

url

Tablo Hesabı URL'si

url: string

Özellik Değeri

string

Yöntem Ayrıntıları

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

Tabloya varlık ekleyin.

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

Parametreler

entity

TableEntity<T>

Tablo varlığının özellikleri.

options
OperationOptions

Seçenekler parametreleri.

Varlık oluşturma örneği

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!"});

Döndürülenler

createTable(OperationOptions)

tableName değeri istemci oluşturucuya geçirilirken bir tablo oluşturur

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

Parametreler

options
OperationOptions

Seçenekler parametreleri.

Tablo oluşturma örneği

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

Döndürülenler

Promise<void>

deleteEntity(string, string, DeleteTableEntityOptions)

Tabloda belirtilen varlığı siler.

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

Parametreler

partitionKey

string

Varlığın bölüm anahtarı.

rowKey

string

Varlığın satır anahtarı.

options
DeleteTableEntityOptions

Seçenekler parametreleri.

Varlık silme örneği

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>")

Döndürülenler

deleteTable(OperationOptions)

Geçerli tabloyu tüm varlıklarıyla birlikte kalıcı olarak siler.

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

Parametreler

options
OperationOptions

Seçenekler parametreleri.

Tablo silme örneği

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

Döndürülenler

Promise<void>

fromConnectionString(string, string, TableServiceClientOptions)

Bağlantı dizesinden bir TableClient örneği oluşturur.

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

Parametreler

connectionString

string

Hesap bağlantı dizesi veya Azure depolama hesabının SAS bağlantı dizesi. [ Not - Hesap bağlantı dizesi yalnızca NODE.JS çalışma zamanında kullanılabilir. ] Hesap bağlantı dizesi örneği -DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net SAS bağlantı dizesi örneği - 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 işlem hattını yapılandırma seçenekleri.

Döndürülenler

Verilen bağlantı dizesinden yeni bir TableClient.

getAccessPolicy(OperationOptions)

Tabloda belirtilen ve Paylaşılan Erişim İmzaları ile kullanılabilecek tüm depolanmış erişim ilkeleriyle ilgili ayrıntıları alır.

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

Parametreler

options
OperationOptions

Seçenekler parametreleri.

Döndürülenler

getEntity<T>(string, string, GetTableEntityOptions)

Tabloda tek bir varlık döndürür.

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

Parametreler

partitionKey

string

Varlığın bölüm anahtarı.

rowKey

string

Varlığın satır anahtarı.

options
GetTableEntityOptions

Seçenekler parametreleri.

Varlık alma örneği

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

Döndürülenler

listEntities<T>(ListTableEntitiesOptions)

Tablodaki varlıkları sorgular.

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

Parametreler

options
ListTableEntitiesOptions

Seçenekler parametreleri.

Varlıkların listelendiği örnek

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

Döndürülenler

setAccessPolicy(SignedIdentifier[], OperationOptions)

Paylaşılan Erişim İmzaları ile kullanılabilecek tablo için depolanan erişim ilkelerini ayarlar.

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

Parametreler

tableAcl

SignedIdentifier[]

Tablonun Access Control Listesi.

options
OperationOptions

Seçenekler parametreleri.

Döndürülenler

submitTransaction(TransactionAction[])

Bir dizi eylemden oluşan bir İşlem gönderir. Eylemleri liste olarak sağlayabilir veya işlemi oluşturmaya yardımcı olması için TableTransaction'ı kullanabilirsiniz.

Örnek kullanım:

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 ile örnek kullanım:

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>

Parametreler

actions

TransactionAction[]

gerçekleştirilecek eylemi ve eylemin gerçekleştirleneceği varlığı içeren tanımlama grubu

Döndürülenler

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

Tablodaki bir varlığı güncelleştirin.

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

Parametreler

entity

TableEntity<T>

Güncelleştirilecek varlığın özellikleri.

mode
UpdateMode

Varlığı güncelleştirmek için farklı modlar: - Birleştirme: Varlığın özelliklerini mevcut varlığı değiştirmeden güncelleştirerek varlığı Güncelleştirmeler. - Değiştir: Varlığın tamamını değiştirerek var olan bir varlığı Güncelleştirmeler.

options
UpdateTableEntityOptions

Seçenekler parametreleri.

Varlığı güncelleştirme örneği

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")

Döndürülenler

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

Tabloya bir varlık ekleyin.

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

Parametreler

entity

TableEntity<T>

Tablo varlığının özellikleri.

mode
UpdateMode

Varlığı güncelleştirmek için farklı modlar: - Birleştirme: Varlığın özelliklerini mevcut varlığı değiştirmeden güncelleştirerek varlığı Güncelleştirmeler. - Değiştir: Varlığın tamamını değiştirerek var olan bir varlığı Güncelleştirmeler.

options
OperationOptions

Seçenekler parametreleri.

Bir varlığın upserting örneği

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")

Döndürülenler