appwrite
Version:
Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API
396 lines (395 loc) • 23.4 kB
TypeScript
import { Client } from '../client';
import type { Models } from '../models';
export declare class TablesDB {
client: Client;
constructor(client: Client);
/**
* List transactions across all databases.
*
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries).
* @throws {AppwriteException}
* @returns {Promise<Models.TransactionList>}
*/
listTransactions(params?: {
queries?: string[];
}): Promise<Models.TransactionList>;
/**
* List transactions across all databases.
*
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries).
* @throws {AppwriteException}
* @returns {Promise<Models.TransactionList>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
listTransactions(queries?: string[]): Promise<Models.TransactionList>;
/**
* Create a new transaction.
*
* @param {number} params.ttl - Seconds before the transaction expires.
* @throws {AppwriteException}
* @returns {Promise<Models.Transaction>}
*/
createTransaction(params?: {
ttl?: number;
}): Promise<Models.Transaction>;
/**
* Create a new transaction.
*
* @param {number} ttl - Seconds before the transaction expires.
* @throws {AppwriteException}
* @returns {Promise<Models.Transaction>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
createTransaction(ttl?: number): Promise<Models.Transaction>;
/**
* Get a transaction by its unique ID.
*
* @param {string} params.transactionId - Transaction ID.
* @throws {AppwriteException}
* @returns {Promise<Models.Transaction>}
*/
getTransaction(params: {
transactionId: string;
}): Promise<Models.Transaction>;
/**
* Get a transaction by its unique ID.
*
* @param {string} transactionId - Transaction ID.
* @throws {AppwriteException}
* @returns {Promise<Models.Transaction>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
getTransaction(transactionId: string): Promise<Models.Transaction>;
/**
* Update a transaction, to either commit or roll back its operations.
*
* @param {string} params.transactionId - Transaction ID.
* @param {boolean} params.commit - Commit transaction?
* @param {boolean} params.rollback - Rollback transaction?
* @throws {AppwriteException}
* @returns {Promise<Models.Transaction>}
*/
updateTransaction(params: {
transactionId: string;
commit?: boolean;
rollback?: boolean;
}): Promise<Models.Transaction>;
/**
* Update a transaction, to either commit or roll back its operations.
*
* @param {string} transactionId - Transaction ID.
* @param {boolean} commit - Commit transaction?
* @param {boolean} rollback - Rollback transaction?
* @throws {AppwriteException}
* @returns {Promise<Models.Transaction>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
updateTransaction(transactionId: string, commit?: boolean, rollback?: boolean): Promise<Models.Transaction>;
/**
* Delete a transaction by its unique ID.
*
* @param {string} params.transactionId - Transaction ID.
* @throws {AppwriteException}
* @returns {Promise<{}>}
*/
deleteTransaction(params: {
transactionId: string;
}): Promise<{}>;
/**
* Delete a transaction by its unique ID.
*
* @param {string} transactionId - Transaction ID.
* @throws {AppwriteException}
* @returns {Promise<{}>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
deleteTransaction(transactionId: string): Promise<{}>;
/**
* Create multiple operations in a single transaction.
*
* @param {string} params.transactionId - Transaction ID.
* @param {object[]} params.operations - Array of staged operations.
* @throws {AppwriteException}
* @returns {Promise<Models.Transaction>}
*/
createOperations(params: {
transactionId: string;
operations?: object[];
}): Promise<Models.Transaction>;
/**
* Create multiple operations in a single transaction.
*
* @param {string} transactionId - Transaction ID.
* @param {object[]} operations - Array of staged operations.
* @throws {AppwriteException}
* @returns {Promise<Models.Transaction>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
createOperations(transactionId: string, operations?: object[]): Promise<Models.Transaction>;
/**
* Get a list of all the user's rows in a given table. You can use the query params to filter your results.
*
* @param {string} params.databaseId - Database ID.
* @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table).
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
* @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction.
* @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
* @throws {AppwriteException}
* @returns {Promise<Models.RowList<Row>>}
*/
listRows<Row extends Models.Row = Models.DefaultRow>(params: {
databaseId: string;
tableId: string;
queries?: string[];
transactionId?: string;
total?: boolean;
}): Promise<Models.RowList<Row>>;
/**
* Get a list of all the user's rows in a given table. You can use the query params to filter your results.
*
* @param {string} databaseId - Database ID.
* @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table).
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
* @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction.
* @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
* @throws {AppwriteException}
* @returns {Promise<Models.RowList<Row>>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
listRows<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, queries?: string[], transactionId?: string, total?: boolean): Promise<Models.RowList<Row>>;
/**
* Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console.
*
* @param {string} params.databaseId - Database ID.
* @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows.
* @param {string} params.rowId - Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
* @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} params.data - Row data as JSON object.
* @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
* @param {string} params.transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise<Row>}
*/
createRow<Row extends Models.Row = Models.DefaultRow>(params: {
databaseId: string;
tableId: string;
rowId: string;
data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>;
permissions?: string[];
transactionId?: string;
}): Promise<Row>;
/**
* Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console.
*
* @param {string} databaseId - Database ID.
* @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows.
* @param {string} rowId - Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
* @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} data - Row data as JSON object.
* @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
* @param {string} transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise<Row>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
createRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], transactionId?: string): Promise<Row>;
/**
* Get a row by its unique ID. This endpoint response returns a JSON object with the row data.
*
* @param {string} params.databaseId - Database ID.
* @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable).
* @param {string} params.rowId - Row ID.
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
* @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction.
* @throws {AppwriteException}
* @returns {Promise<Row>}
*/
getRow<Row extends Models.Row = Models.DefaultRow>(params: {
databaseId: string;
tableId: string;
rowId: string;
queries?: string[];
transactionId?: string;
}): Promise<Row>;
/**
* Get a row by its unique ID. This endpoint response returns a JSON object with the row data.
*
* @param {string} databaseId - Database ID.
* @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable).
* @param {string} rowId - Row ID.
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
* @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction.
* @throws {AppwriteException}
* @returns {Promise<Row>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
getRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, queries?: string[], transactionId?: string): Promise<Row>;
/**
* Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console.
*
* @param {string} params.databaseId - Database ID.
* @param {string} params.tableId - Table ID.
* @param {string} params.rowId - Row ID.
* @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include all required columns of the row to be created or updated.
* @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
* @param {string} params.transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise<Row>}
*/
upsertRow<Row extends Models.Row = Models.DefaultRow>(params: {
databaseId: string;
tableId: string;
rowId: string;
data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>;
permissions?: string[];
transactionId?: string;
}): Promise<Row>;
/**
* Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console.
*
* @param {string} databaseId - Database ID.
* @param {string} tableId - Table ID.
* @param {string} rowId - Row ID.
* @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include all required columns of the row to be created or updated.
* @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
* @param {string} transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise<Row>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
upsertRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[], transactionId?: string): Promise<Row>;
/**
* Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated.
*
* @param {string} params.databaseId - Database ID.
* @param {string} params.tableId - Table ID.
* @param {string} params.rowId - Row ID.
* @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include only columns and value pairs to be updated.
* @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
* @param {string} params.transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise<Row>}
*/
updateRow<Row extends Models.Row = Models.DefaultRow>(params: {
databaseId: string;
tableId: string;
rowId: string;
data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>;
permissions?: string[];
transactionId?: string;
}): Promise<Row>;
/**
* Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated.
*
* @param {string} databaseId - Database ID.
* @param {string} tableId - Table ID.
* @param {string} rowId - Row ID.
* @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include only columns and value pairs to be updated.
* @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
* @param {string} transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise<Row>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
updateRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, permissions?: string[], transactionId?: string): Promise<Row>;
/**
* Delete a row by its unique ID.
*
* @param {string} params.databaseId - Database ID.
* @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable).
* @param {string} params.rowId - Row ID.
* @param {string} params.transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise<{}>}
*/
deleteRow(params: {
databaseId: string;
tableId: string;
rowId: string;
transactionId?: string;
}): Promise<{}>;
/**
* Delete a row by its unique ID.
*
* @param {string} databaseId - Database ID.
* @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable).
* @param {string} rowId - Row ID.
* @param {string} transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise<{}>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
deleteRow(databaseId: string, tableId: string, rowId: string, transactionId?: string): Promise<{}>;
/**
* Decrement a specific column of a row by a given value.
*
* @param {string} params.databaseId - Database ID.
* @param {string} params.tableId - Table ID.
* @param {string} params.rowId - Row ID.
* @param {string} params.column - Column key.
* @param {number} params.value - Value to increment the column by. The value must be a number.
* @param {number} params.min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.
* @param {string} params.transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise<Row>}
*/
decrementRowColumn<Row extends Models.Row = Models.DefaultRow>(params: {
databaseId: string;
tableId: string;
rowId: string;
column: string;
value?: number;
min?: number;
transactionId?: string;
}): Promise<Row>;
/**
* Decrement a specific column of a row by a given value.
*
* @param {string} databaseId - Database ID.
* @param {string} tableId - Table ID.
* @param {string} rowId - Row ID.
* @param {string} column - Column key.
* @param {number} value - Value to increment the column by. The value must be a number.
* @param {number} min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.
* @param {string} transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise<Row>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
decrementRowColumn<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, column: string, value?: number, min?: number, transactionId?: string): Promise<Row>;
/**
* Increment a specific column of a row by a given value.
*
* @param {string} params.databaseId - Database ID.
* @param {string} params.tableId - Table ID.
* @param {string} params.rowId - Row ID.
* @param {string} params.column - Column key.
* @param {number} params.value - Value to increment the column by. The value must be a number.
* @param {number} params.max - Maximum value for the column. If the current value is greater than this value, an error will be thrown.
* @param {string} params.transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise<Row>}
*/
incrementRowColumn<Row extends Models.Row = Models.DefaultRow>(params: {
databaseId: string;
tableId: string;
rowId: string;
column: string;
value?: number;
max?: number;
transactionId?: string;
}): Promise<Row>;
/**
* Increment a specific column of a row by a given value.
*
* @param {string} databaseId - Database ID.
* @param {string} tableId - Table ID.
* @param {string} rowId - Row ID.
* @param {string} column - Column key.
* @param {number} value - Value to increment the column by. The value must be a number.
* @param {number} max - Maximum value for the column. If the current value is greater than this value, an error will be thrown.
* @param {string} transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise<Row>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
incrementRowColumn<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, column: string, value?: number, max?: number, transactionId?: string): Promise<Row>;
}