Files

4361 lines
118 KiB
Dart

part of '../dart_appwrite.dart';
/// The Databases service allows you to create structured collections of
/// documents, query and filter lists of documents
class Databases extends Service {
Databases(super.client);
/// Get a list of all databases from the current Appwrite project. You can use
/// the search parameter to filter your results.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.list` instead.',
)
Future<models.DatabaseList> list({
List<String>? queries,
String? search,
bool? total,
}) async {
final String apiPath = '/databases';
final Map<String, dynamic> apiParams = {
if (queries != null) 'queries': queries,
if (search != null) 'search': search,
if (total != null) 'total': total,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.get,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.DatabaseList.fromMap(res.data);
}
/// Create a new Database.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.create` instead.',
)
Future<models.Database> create({
required String databaseId,
required String name,
bool? enabled,
String? description,
}) async {
final String apiPath = '/databases';
final Map<String, dynamic> apiParams = {
'databaseId': databaseId,
'name': name,
if (enabled != null) 'enabled': enabled,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Database.fromMap(res.data);
}
/// List transactions across all databases.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.',
)
Future<models.TransactionList> listTransactions({
List<String>? queries,
bool? total,
}) async {
final String apiPath = '/databases/transactions';
final Map<String, dynamic> apiParams = {
if (queries != null) 'queries': queries,
if (total != null) 'total': total,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.get,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.TransactionList.fromMap(res.data);
}
/// Create a new transaction.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.',
)
Future<models.Transaction> createTransaction({
int? ttl,
}) async {
final String apiPath = '/databases/transactions';
final Map<String, dynamic> apiParams = {
if (ttl != null) 'ttl': ttl,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Transaction.fromMap(res.data);
}
/// Get a transaction by its unique ID.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.',
)
Future<models.Transaction> getTransaction({
required String transactionId,
}) async {
if (transactionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "transactionId"',
);
}
final String apiPath = '/databases/transactions/{transactionId}'.replaceAll(
'{transactionId}',
_encodePath(transactionId),
);
final Map<String, dynamic> apiParams = {};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.get,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Transaction.fromMap(res.data);
}
/// Update a transaction, to either commit or roll back its operations.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.',
)
Future<models.Transaction> updateTransaction({
required String transactionId,
bool? commit,
bool? rollback,
}) async {
if (transactionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "transactionId"',
);
}
final String apiPath = '/databases/transactions/{transactionId}'.replaceAll(
'{transactionId}',
_encodePath(transactionId),
);
final Map<String, dynamic> apiParams = {
if (commit != null) 'commit': commit,
if (rollback != null) 'rollback': rollback,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Transaction.fromMap(res.data);
}
/// Delete a transaction by its unique ID.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.',
)
Future deleteTransaction({
required String transactionId,
}) async {
if (transactionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "transactionId"',
);
}
final String apiPath = '/databases/transactions/{transactionId}'.replaceAll(
'{transactionId}',
_encodePath(transactionId),
);
final Map<String, dynamic> apiParams = {};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.delete,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return res.data;
}
/// Create multiple operations in a single transaction.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.',
)
Future<models.Transaction> createOperations({
required String transactionId,
List<Map>? operations,
}) async {
if (transactionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "transactionId"',
);
}
final String apiPath =
'/databases/transactions/{transactionId}/operations'.replaceAll(
'{transactionId}',
_encodePath(transactionId),
);
final Map<String, dynamic> apiParams = {
if (operations != null) 'operations': operations,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Transaction.fromMap(res.data);
}
/// Get a database by its unique ID. This endpoint response returns a JSON
/// object with the database metadata.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.get` instead.',
)
Future<models.Database> get({
required String databaseId,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
final String apiPath = '/databases/{databaseId}'.replaceAll(
'{databaseId}',
_encodePath(databaseId),
);
final Map<String, dynamic> apiParams = {};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.get,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Database.fromMap(res.data);
}
/// Update a database by its unique ID.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.update` instead.',
)
Future<models.Database> update({
required String databaseId,
String? name,
bool? enabled,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
final String apiPath = '/databases/{databaseId}'.replaceAll(
'{databaseId}',
_encodePath(databaseId),
);
final Map<String, dynamic> apiParams = {
if (name != null) 'name': name,
if (enabled != null) 'enabled': enabled,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.put,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Database.fromMap(res.data);
}
/// Delete a database by its unique ID. Only API keys with with databases.write
/// scope can delete a database.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.delete` instead.',
)
Future delete({
required String databaseId,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
final String apiPath = '/databases/{databaseId}'.replaceAll(
'{databaseId}',
_encodePath(databaseId),
);
final Map<String, dynamic> apiParams = {};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.delete,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return res.data;
}
/// Get a list of all collections that belong to the provided databaseId. You
/// can use the search parameter to filter your results.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.listTables` instead.',
)
Future<models.CollectionList> listCollections({
required String databaseId,
List<String>? queries,
String? search,
bool? total,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
final String apiPath = '/databases/{databaseId}/collections'.replaceAll(
'{databaseId}',
_encodePath(databaseId),
);
final Map<String, dynamic> apiParams = {
if (queries != null) 'queries': queries,
if (search != null) 'search': search,
if (total != null) 'total': total,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.get,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.CollectionList.fromMap(res.data);
}
/// Create a new Collection. Before using this route, you should create a new
/// database resource using either a [server
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
/// API or directly from your database console.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createTable` instead.',
)
Future<models.Collection> createCollection({
required String databaseId,
required String collectionId,
required String name,
List<String>? permissions,
bool? documentSecurity,
bool? enabled,
List<Map>? attributes,
List<Map>? indexes,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
final String apiPath = '/databases/{databaseId}/collections'.replaceAll(
'{databaseId}',
_encodePath(databaseId),
);
final Map<String, dynamic> apiParams = {
'collectionId': collectionId,
'name': name,
if (permissions != null) 'permissions': permissions,
if (documentSecurity != null) 'documentSecurity': documentSecurity,
if (enabled != null) 'enabled': enabled,
if (attributes != null) 'attributes': attributes,
if (indexes != null) 'indexes': indexes,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Collection.fromMap(res.data);
}
/// Get a collection by its unique ID. This endpoint response returns a JSON
/// object with the collection metadata.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.getTable` instead.',
)
Future<models.Collection> getCollection({
required String databaseId,
required String collectionId,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath = '/databases/{databaseId}/collections/{collectionId}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.get,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Collection.fromMap(res.data);
}
/// Update a collection by its unique ID.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateTable` instead.',
)
Future<models.Collection> updateCollection({
required String databaseId,
required String collectionId,
String? name,
List<String>? permissions,
bool? documentSecurity,
bool? enabled,
bool? purge,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath = '/databases/{databaseId}/collections/{collectionId}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
if (name != null) 'name': name,
if (permissions != null) 'permissions': permissions,
if (documentSecurity != null) 'documentSecurity': documentSecurity,
if (enabled != null) 'enabled': enabled,
if (purge != null) 'purge': purge,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.put,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Collection.fromMap(res.data);
}
/// Delete a collection by its unique ID. Only users with write permissions
/// have access to delete this resource.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTable` instead.',
)
Future deleteCollection({
required String databaseId,
required String collectionId,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath = '/databases/{databaseId}/collections/{collectionId}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.delete,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return res.data;
}
/// List attributes in the collection.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.listColumns` instead.',
)
Future<models.AttributeList> listAttributes({
required String databaseId,
required String collectionId,
List<String>? queries,
bool? total,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
if (queries != null) 'queries': queries,
if (total != null) 'total': total,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.get,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeList.fromMap(res.data);
}
/// Create a bigint attribute. Optionally, minimum and maximum values can be
/// provided.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createBigIntColumn` instead.',
)
Future<models.AttributeBigint> createBigIntAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
int? min,
int? max,
int? xdefault,
bool? array,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/bigint'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'required': xrequired,
if (min != null) 'min': min,
if (max != null) 'max': max,
if (xdefault != null) 'default': xdefault,
if (array != null) 'array': array,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeBigint.fromMap(res.data);
}
/// Update a bigint attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateBigIntColumn` instead.',
)
Future<models.AttributeBigint> updateBigIntAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
required int? xdefault,
int? min,
int? max,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
if (min != null) 'min': min,
if (max != null) 'max': max,
'default': xdefault,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeBigint.fromMap(res.data);
}
/// Create a boolean attribute.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createBooleanColumn` instead.',
)
Future<models.AttributeBoolean> createBooleanAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
bool? xdefault,
bool? array,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/boolean'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (array != null) 'array': array,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeBoolean.fromMap(res.data);
}
/// Update a boolean attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateBooleanColumn` instead.',
)
Future<models.AttributeBoolean> updateBooleanAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
required bool? xdefault,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
'default': xdefault,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeBoolean.fromMap(res.data);
}
/// Create a date time attribute according to the ISO 8601 standard.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createDatetimeColumn` instead.',
)
Future<models.AttributeDatetime> createDatetimeAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
String? xdefault,
bool? array,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/datetime'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (array != null) 'array': array,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeDatetime.fromMap(res.data);
}
/// Update a date time attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateDatetimeColumn` instead.',
)
Future<models.AttributeDatetime> updateDatetimeAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
required String? xdefault,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
'default': xdefault,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeDatetime.fromMap(res.data);
}
/// Create an email attribute.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createEmailColumn` instead.',
)
Future<models.AttributeEmail> createEmailAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
String? xdefault,
bool? array,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/email'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (array != null) 'array': array,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeEmail.fromMap(res.data);
}
/// Update an email attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateEmailColumn` instead.',
)
Future<models.AttributeEmail> updateEmailAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
required String? xdefault,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
'default': xdefault,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeEmail.fromMap(res.data);
}
/// Create an enum attribute. The `elements` param acts as a white-list of
/// accepted values for this attribute.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createEnumColumn` instead.',
)
Future<models.AttributeEnum> createEnumAttribute({
required String databaseId,
required String collectionId,
required String key,
required List<String> elements,
required bool xrequired,
String? xdefault,
bool? array,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/enum'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'elements': elements,
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (array != null) 'array': array,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeEnum.fromMap(res.data);
}
/// Update an enum attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateEnumColumn` instead.',
)
Future<models.AttributeEnum> updateEnumAttribute({
required String databaseId,
required String collectionId,
required String key,
required List<String> elements,
required bool xrequired,
required String? xdefault,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'elements': elements,
'required': xrequired,
'default': xdefault,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeEnum.fromMap(res.data);
}
/// Create a float attribute. Optionally, minimum and maximum values can be
/// provided.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createFloatColumn` instead.',
)
Future<models.AttributeFloat> createFloatAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
double? min,
double? max,
double? xdefault,
bool? array,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/float'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'required': xrequired,
if (min != null) 'min': min,
if (max != null) 'max': max,
if (xdefault != null) 'default': xdefault,
if (array != null) 'array': array,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeFloat.fromMap(res.data);
}
/// Update a float attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateFloatColumn` instead.',
)
Future<models.AttributeFloat> updateFloatAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
required double? xdefault,
double? min,
double? max,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
if (min != null) 'min': min,
if (max != null) 'max': max,
'default': xdefault,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeFloat.fromMap(res.data);
}
/// Create an integer attribute. Optionally, minimum and maximum values can be
/// provided.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createIntegerColumn` instead.',
)
Future<models.AttributeInteger> createIntegerAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
int? min,
int? max,
int? xdefault,
bool? array,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/integer'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'required': xrequired,
if (min != null) 'min': min,
if (max != null) 'max': max,
if (xdefault != null) 'default': xdefault,
if (array != null) 'array': array,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeInteger.fromMap(res.data);
}
/// Update an integer attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateIntegerColumn` instead.',
)
Future<models.AttributeInteger> updateIntegerAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
required int? xdefault,
int? min,
int? max,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
if (min != null) 'min': min,
if (max != null) 'max': max,
'default': xdefault,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeInteger.fromMap(res.data);
}
/// Create IP address attribute.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createIpColumn` instead.',
)
Future<models.AttributeIp> createIpAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
String? xdefault,
bool? array,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/ip'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (array != null) 'array': array,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeIp.fromMap(res.data);
}
/// Update an ip attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateIpColumn` instead.',
)
Future<models.AttributeIp> updateIpAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
required String? xdefault,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
'default': xdefault,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeIp.fromMap(res.data);
}
/// Create a geometric line attribute.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createLineColumn` instead.',
)
Future<models.AttributeLine> createLineAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
List<List>? xdefault,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/line'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeLine.fromMap(res.data);
}
/// Update a line attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateLineColumn` instead.',
)
Future<models.AttributeLine> updateLineAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
List<List>? xdefault,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeLine.fromMap(res.data);
}
/// Create a longtext attribute.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createLongtextColumn` instead.',
)
Future<models.AttributeLongtext> createLongtextAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
String? xdefault,
bool? array,
bool? encrypt,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/longtext'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (array != null) 'array': array,
if (encrypt != null) 'encrypt': encrypt,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeLongtext.fromMap(res.data);
}
/// Update a longtext attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateLongtextColumn` instead.',
)
Future<models.AttributeLongtext> updateLongtextAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
required String? xdefault,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
'default': xdefault,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeLongtext.fromMap(res.data);
}
/// Create a mediumtext attribute.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createMediumtextColumn` instead.',
)
Future<models.AttributeMediumtext> createMediumtextAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
String? xdefault,
bool? array,
bool? encrypt,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (array != null) 'array': array,
if (encrypt != null) 'encrypt': encrypt,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeMediumtext.fromMap(res.data);
}
/// Update a mediumtext attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateMediumtextColumn` instead.',
)
Future<models.AttributeMediumtext> updateMediumtextAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
required String? xdefault,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
'default': xdefault,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeMediumtext.fromMap(res.data);
}
/// Create a geometric point attribute.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createPointColumn` instead.',
)
Future<models.AttributePoint> createPointAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
List<double>? xdefault,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/point'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributePoint.fromMap(res.data);
}
/// Update a point attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updatePointColumn` instead.',
)
Future<models.AttributePoint> updatePointAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
List<double>? xdefault,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributePoint.fromMap(res.data);
}
/// Create a geometric polygon attribute.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createPolygonColumn` instead.',
)
Future<models.AttributePolygon> createPolygonAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
List<List>? xdefault,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/polygon'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributePolygon.fromMap(res.data);
}
/// Update a polygon attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updatePolygonColumn` instead.',
)
Future<models.AttributePolygon> updatePolygonAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
List<List>? xdefault,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributePolygon.fromMap(res.data);
}
/// Create relationship attribute. [Learn more about relationship
/// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes).
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createRelationshipColumn` instead.',
)
Future<models.AttributeRelationship> createRelationshipAttribute({
required String databaseId,
required String collectionId,
required String relatedCollectionId,
required enums.RelationshipType type,
bool? twoWay,
String? key,
String? twoWayKey,
enums.RelationMutate? onDelete,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/relationship'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'relatedCollectionId': relatedCollectionId,
'type': type.value,
if (twoWay != null) 'twoWay': twoWay,
if (key != null) 'key': key,
if (twoWayKey != null) 'twoWayKey': twoWayKey,
if (onDelete != null) 'onDelete': onDelete?.value,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeRelationship.fromMap(res.data);
}
/// Update relationship attribute. [Learn more about relationship
/// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes).
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead.',
)
Future<models.AttributeRelationship> updateRelationshipAttribute({
required String databaseId,
required String collectionId,
required String key,
enums.RelationMutate? onDelete,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
if (onDelete != null) 'onDelete': onDelete?.value,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeRelationship.fromMap(res.data);
}
/// Create a string attribute.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createStringColumn` instead.',
)
Future<models.AttributeString> createStringAttribute({
required String databaseId,
required String collectionId,
required String key,
required int size,
required bool xrequired,
String? xdefault,
bool? array,
bool? encrypt,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/string'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'size': size,
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (array != null) 'array': array,
if (encrypt != null) 'encrypt': encrypt,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeString.fromMap(res.data);
}
/// Update a string attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateStringColumn` instead.',
)
Future<models.AttributeString> updateStringAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
required String? xdefault,
int? size,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
'default': xdefault,
if (size != null) 'size': size,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeString.fromMap(res.data);
}
/// Create a text attribute.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createTextColumn` instead.',
)
Future<models.AttributeText> createTextAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
String? xdefault,
bool? array,
bool? encrypt,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/text'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (array != null) 'array': array,
if (encrypt != null) 'encrypt': encrypt,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeText.fromMap(res.data);
}
/// Update a text attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead.',
)
Future<models.AttributeText> updateTextAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
required String? xdefault,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
'default': xdefault,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeText.fromMap(res.data);
}
/// Create a URL attribute.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createUrlColumn` instead.',
)
Future<models.AttributeUrl> createUrlAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
String? xdefault,
bool? array,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/url'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (array != null) 'array': array,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeUrl.fromMap(res.data);
}
/// Update an url attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateUrlColumn` instead.',
)
Future<models.AttributeUrl> updateUrlAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
required String? xdefault,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
'default': xdefault,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeUrl.fromMap(res.data);
}
/// Create a varchar attribute.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createVarcharColumn` instead.',
)
Future<models.AttributeVarchar> createVarcharAttribute({
required String databaseId,
required String collectionId,
required String key,
required int size,
required bool xrequired,
String? xdefault,
bool? array,
bool? encrypt,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/varchar'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'size': size,
'required': xrequired,
if (xdefault != null) 'default': xdefault,
if (array != null) 'array': array,
if (encrypt != null) 'encrypt': encrypt,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeVarchar.fromMap(res.data);
}
/// Update a varchar attribute. Changing the `default` value will not update
/// already existing documents.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateVarcharColumn` instead.',
)
Future<models.AttributeVarchar> updateVarcharAttribute({
required String databaseId,
required String collectionId,
required String key,
required bool xrequired,
required String? xdefault,
int? size,
String? newKey,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {
'required': xrequired,
'default': xdefault,
if (size != null) 'size': size,
if (newKey != null) 'newKey': newKey,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.AttributeVarchar.fromMap(res.data);
}
/// Get attribute by ID.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.getColumn` instead.',
)
Future<models.Model> getAttribute({
required String databaseId,
required String collectionId,
required String key,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.get,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return () {
if (res.data is! Map<String, dynamic>) {
throw StateError(
'Unable to match response to any expected response model.',
);
}
final response = res.data as Map<String, dynamic>;
if (response['type'] == "string" && response['format'] == "email") {
return models.AttributeEmail.fromMap(response);
}
if (response['type'] == "string" && response['format'] == "enum") {
return models.AttributeEnum.fromMap(response);
}
if (response['type'] == "string" && response['format'] == "url") {
return models.AttributeUrl.fromMap(response);
}
if (response['type'] == "string" && response['format'] == "ip") {
return models.AttributeIp.fromMap(response);
}
if (response['type'] == "boolean") {
return models.AttributeBoolean.fromMap(response);
}
if (response['type'] == "bigint") {
return models.AttributeBigint.fromMap(response);
}
if (response['type'] == "integer") {
return models.AttributeInteger.fromMap(response);
}
if (response['type'] == "double") {
return models.AttributeFloat.fromMap(response);
}
if (response['type'] == "datetime") {
return models.AttributeDatetime.fromMap(response);
}
if (response['type'] == "relationship") {
return models.AttributeRelationship.fromMap(response);
}
if (response['type'] == "point") {
return models.AttributePoint.fromMap(response);
}
if (response['type'] == "linestring") {
return models.AttributeLine.fromMap(response);
}
if (response['type'] == "polygon") {
return models.AttributePolygon.fromMap(response);
}
if (response['type'] == "varchar") {
return models.AttributeVarchar.fromMap(response);
}
if (response['type'] == "text") {
return models.AttributeText.fromMap(response);
}
if (response['type'] == "mediumtext") {
return models.AttributeMediumtext.fromMap(response);
}
if (response['type'] == "longtext") {
return models.AttributeLongtext.fromMap(response);
}
if (response['type'] == "string") {
return models.AttributeString.fromMap(response);
}
throw StateError(
'Unable to match response to any expected response model.',
);
}();
}
/// Deletes an attribute.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteColumn` instead.',
)
Future deleteAttribute({
required String databaseId,
required String collectionId,
required String key,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/attributes/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.delete,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return res.data;
}
/// Get a list of all the user's documents in a given collection. You can use
/// the query params to filter your results.
///
/// Documents returned by aggregate, groupBy or distinct queries hold only the
/// attributes they select, group or aggregate, typed as a document types them,
/// with a joined attribute named by its join alias (`alias.attribute`). The
/// response omits their `$id`, `$sequence`, `$createdAt`, `$updatedAt`,
/// `$permissions`, `$databaseId` and `$collectionId` unless they select or
/// group it, and those of a right or full join document that no document of
/// this collection matched. SDK document models fill omitted system attributes
/// with empty values.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.',
)
Future<models.DocumentList> listDocuments({
required String databaseId,
required String collectionId,
List<String>? queries,
String? transactionId,
bool? total,
int? ttl,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/documents'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
if (queries != null) 'queries': queries,
if (transactionId != null) 'transactionId': transactionId,
if (total != null) 'total': total,
if (ttl != null) 'ttl': ttl,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.get,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.DocumentList.fromMap(res.data);
}
/// Create a new Document. Before using this route, you should create a new
/// collection resource using either a [server
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
/// API or directly from your database console.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.',
)
Future<models.Document> createDocument({
required String databaseId,
required String collectionId,
required String documentId,
required Map data,
List<String>? permissions,
String? transactionId,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/documents'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'documentId': documentId,
'data': data,
if (permissions != null) 'permissions': permissions,
if (transactionId != null) 'transactionId': transactionId,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Document.fromMap(res.data);
}
/// Create new Documents. Before using this route, you should create a new
/// collection resource using either a [server
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
/// API or directly from your database console.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createRows` instead.',
)
Future<models.DocumentList> createDocuments({
required String databaseId,
required String collectionId,
required List<Map> documents,
String? transactionId,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/documents'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'documents': documents,
if (transactionId != null) 'transactionId': transactionId,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.DocumentList.fromMap(res.data);
}
/// Create or update Documents. Before using this route, you should create a
/// new collection resource using either a [server
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
/// API or directly from your database console.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead.',
)
Future<models.DocumentList> upsertDocuments({
required String databaseId,
required String collectionId,
required List<Map> documents,
String? transactionId,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/documents'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'documents': documents,
if (transactionId != null) 'transactionId': transactionId,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.put,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.DocumentList.fromMap(res.data);
}
/// Update all documents that match your queries, if no queries are submitted
/// then all documents are updated. You can pass only specific fields to be
/// updated.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateRows` instead.',
)
Future<models.DocumentList> updateDocuments({
required String databaseId,
required String collectionId,
Map? data,
List<String>? queries,
String? transactionId,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/documents'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
if (data != null) 'data': data,
if (queries != null) 'queries': queries,
if (transactionId != null) 'transactionId': transactionId,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.DocumentList.fromMap(res.data);
}
/// Bulk delete documents using queries, if no queries are passed then all
/// documents are deleted.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRows` instead.',
)
Future<models.DocumentList> deleteDocuments({
required String databaseId,
required String collectionId,
List<String>? queries,
String? transactionId,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/documents'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
if (queries != null) 'queries': queries,
if (transactionId != null) 'transactionId': transactionId,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.delete,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.DocumentList.fromMap(res.data);
}
/// Get a list of all the user's documents in a given collection using a POST
/// request. This behaves identically to the list documents endpoint but
/// accepts the queries in the request body, allowing much larger `queries`
/// arrays than can fit in a URL query string.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createQuery` instead.',
)
Future<models.DocumentList> createQuery({
required String databaseId,
required String collectionId,
List<String>? queries,
String? transactionId,
bool? total,
int? ttl,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/documents/query'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
if (queries != null) 'queries': queries,
if (transactionId != null) 'transactionId': transactionId,
if (total != null) 'total': total,
if (ttl != null) 'ttl': ttl,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.DocumentList.fromMap(res.data);
}
/// Get a document by its unique ID. This endpoint response returns a JSON
/// object with the document data.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.',
)
Future<models.Document> getDocument({
required String databaseId,
required String collectionId,
required String documentId,
List<String>? queries,
String? transactionId,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (documentId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "documentId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{documentId}',
_encodePath(documentId),
);
final Map<String, dynamic> apiParams = {
if (queries != null) 'queries': queries,
if (transactionId != null) 'transactionId': transactionId,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.get,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Document.fromMap(res.data);
}
/// Create or update a Document. Before using this route, you should create a
/// new collection resource using either a [server
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
/// API or directly from your database console.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.',
)
Future<models.Document> upsertDocument({
required String databaseId,
required String collectionId,
required String documentId,
Map? data,
List<String>? permissions,
String? transactionId,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (documentId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "documentId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{documentId}',
_encodePath(documentId),
);
final Map<String, dynamic> apiParams = {
if (data != null) 'data': data,
if (permissions != null) 'permissions': permissions,
if (transactionId != null) 'transactionId': transactionId,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.put,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Document.fromMap(res.data);
}
/// Update a document by its unique ID. Using the patch method you can pass
/// only specific fields that will get updated.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.',
)
Future<models.Document> updateDocument({
required String databaseId,
required String collectionId,
required String documentId,
Map? data,
List<String>? permissions,
String? transactionId,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (documentId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "documentId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{documentId}',
_encodePath(documentId),
);
final Map<String, dynamic> apiParams = {
if (data != null) 'data': data,
if (permissions != null) 'permissions': permissions,
if (transactionId != null) 'transactionId': transactionId,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Document.fromMap(res.data);
}
/// Delete a document by its unique ID.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.',
)
Future deleteDocument({
required String databaseId,
required String collectionId,
required String documentId,
String? transactionId,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (documentId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "documentId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{documentId}',
_encodePath(documentId),
);
final Map<String, dynamic> apiParams = {
if (transactionId != null) 'transactionId': transactionId,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.delete,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return res.data;
}
/// Decrement a specific attribute of a document by a given value.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.',
)
Future<models.Document> decrementDocumentAttribute({
required String databaseId,
required String collectionId,
required String documentId,
required String attribute,
double? value,
double? min,
String? transactionId,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (documentId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "documentId"',
);
}
if (attribute.isEmpty) {
throw AppwriteException(
'Missing required parameter: "attribute"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{documentId}',
_encodePath(documentId),
)
.replaceAll(
'{attribute}',
_encodePath(attribute),
);
final Map<String, dynamic> apiParams = {
if (value != null) 'value': value,
if (min != null) 'min': min,
if (transactionId != null) 'transactionId': transactionId,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Document.fromMap(res.data);
}
/// Increment a specific attribute of a document by a given value.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.',
)
Future<models.Document> incrementDocumentAttribute({
required String databaseId,
required String collectionId,
required String documentId,
required String attribute,
double? value,
double? max,
String? transactionId,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (documentId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "documentId"',
);
}
if (attribute.isEmpty) {
throw AppwriteException(
'Missing required parameter: "attribute"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{documentId}',
_encodePath(documentId),
)
.replaceAll(
'{attribute}',
_encodePath(attribute),
);
final Map<String, dynamic> apiParams = {
if (value != null) 'value': value,
if (max != null) 'max': max,
if (transactionId != null) 'transactionId': transactionId,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.patch,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Document.fromMap(res.data);
}
/// List indexes in the collection.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.listIndexes` instead.',
)
Future<models.IndexList> listIndexes({
required String databaseId,
required String collectionId,
List<String>? queries,
bool? total,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/indexes'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
if (queries != null) 'queries': queries,
if (total != null) 'total': total,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.get,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.IndexList.fromMap(res.data);
}
/// Creates an index on the attributes listed. Your index should include all
/// the attributes you will query in a single request.
/// Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`.
/// `trigram` is only available on PostgreSQL and lets `contains`,
/// `startsWith`, and `endsWith` queries on string attributes use an index.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.createIndex` instead.',
)
Future<models.Index> createIndex({
required String databaseId,
required String collectionId,
required String key,
required enums.DatabasesIndexType type,
required List<String> attributes,
List<enums.OrderBy>? orders,
List<int>? lengths,
String? description,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/indexes'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
);
final Map<String, dynamic> apiParams = {
'key': key,
'type': type.value,
'attributes': attributes,
if (orders != null) 'orders': orders?.map((e) => e.value).toList(),
if (lengths != null) 'lengths': lengths,
if (description != null) 'description': description,
};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Index.fromMap(res.data);
}
/// Get an index by its unique ID.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.getIndex` instead.',
)
Future<models.Index> getIndex({
required String databaseId,
required String collectionId,
required String key,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/indexes/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.get,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return models.Index.fromMap(res.data);
}
/// Delete an index.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteIndex` instead.',
)
Future deleteIndex({
required String databaseId,
required String collectionId,
required String key,
}) async {
if (databaseId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "databaseId"',
);
}
if (collectionId.isEmpty) {
throw AppwriteException(
'Missing required parameter: "collectionId"',
);
}
if (key.isEmpty) {
throw AppwriteException(
'Missing required parameter: "key"',
);
}
final String apiPath =
'/databases/{databaseId}/collections/{collectionId}/indexes/{key}'
.replaceAll(
'{databaseId}',
_encodePath(databaseId),
)
.replaceAll(
'{collectionId}',
_encodePath(collectionId),
)
.replaceAll(
'{key}',
_encodePath(key),
);
final Map<String, dynamic> apiParams = {};
final Map<String, String> apiHeaders = {
'X-Appwrite-Project': client.config['project'] ?? '',
'content-type': 'application/json',
'accept': 'application/json',
};
final res = await client.call(
HttpMethod.delete,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);
return res.data;
}
}