@akadenia/azure-storage
Version:
Microsoft Azure storage helper methods
76 lines (74 loc) • 3.22 kB
TypeScript
import { GetTableEntityResponse, ListTableEntitiesOptions, TableClient, TableEntity, TableEntityResult } from "@azure/data-tables";
/**
* @interface ITableEntity - An interface that represents an entity in an azure table
The following characters are not allowed in values for the PartitionKey and RowKey properties:
The forward slash (/) character
The backslash (\) character
The number sign (#) character
The question mark (?) character
Control characters from U+0000 to U+001F, including:
The horizontal tab (\t) character
The linefeed (\n) character
The carriage return (\r) character
Control characters from U+007F to U+009F
The partition key and row key may be a string value up to 1024 characters in size.
*/
export interface ITableEntity extends TableEntity {
readonly timestamp?: Date;
[key: string]: any;
}
export interface TableManagedIdentityOptions {
accountName: string;
tableName: string;
managedIdentityClientId?: string;
}
/**
* @class TableStorage - A class that contains azure table storage helpers
*/
export declare class TableStorage {
private tableClient;
constructor(connectionString: string, tableName: string);
constructor(managedIdentityOptions: TableManagedIdentityOptions);
/**
* @returns {TableClient} - A TableClient object
*/
getTableClient(): TableClient;
/** Creates a table in the storage account
* @returns {Promise<void>} - A promise that resolves when the table is created
* @returns {Promise<boolean>} - A promise that resolves to true if the table was created
**/
createTable(): Promise<boolean>;
/** Deletes a table in the storage account
* @returns {Promise<void>} - A promise that resolves when the table is deleted
* @returns {Promise<boolean>} - A promise that resolves to true if the table was deleted
**/
deleteTable(): Promise<boolean>;
/**
* @param {ITableEntity} entity - The entity to insert
* @returns {Promise<boolean>} - A promise that resolves to true if the entity was inserted
*/
insert(entity: ITableEntity): Promise<boolean>;
/**
* @param {ITableEntity} entity - The entity to update
* @returns {Promise<boolean>} - A promise that resolves to true if the entity was updated
*/
update(entity: ITableEntity): Promise<boolean>;
/**
* @param {ITableEntity} entity - The entity to upsert
* @returns {Promise<boolean>} - A promise that resolves to true if the entity was upserted
*/
upsert(entity: ITableEntity): Promise<boolean>;
/**
* @param {string} partitionKey - The partition key
* @param {string} rowKey - The row key
* @returns {Promise<ITableEntity>} - The deleted entity
*/
delete(partitionKey: string, rowKey: string): Promise<boolean>;
/**
* @param {string} partitionKey - The partition key
* @param {string} rowKey - The row key
* @returns {Promise<ITableEntity>} - The retrieved entity
*/
get(partitionKey: string, rowKey: string): Promise<GetTableEntityResponse<TableEntityResult<ITableEntity>>>;
list<T extends ITableEntity>(options?: ListTableEntitiesOptions): Promise<T[]>;
}