mirror of
https://github.com/appwrite/sdk-for-flutter.git
synced 2026-04-07 19:27:41 +00:00
Add 1.7 support
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
Client client = Client()
|
||||
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
||||
.setKey(''); //
|
||||
|
||||
Databases databases = Databases(client);
|
||||
|
||||
DocumentList result = await databases.createDocuments(
|
||||
databaseId: '<DATABASE_ID>',
|
||||
collectionId: '<COLLECTION_ID>',
|
||||
documents: [],
|
||||
);
|
||||
@@ -48,27 +48,6 @@ class Databases extends Service {
|
||||
|
||||
}
|
||||
|
||||
/// 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.
|
||||
Future<models.DocumentList> createDocuments({required String databaseId, required String collectionId, required List<Map> documents}) async {
|
||||
final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId);
|
||||
|
||||
final Map<String, dynamic> apiParams = {
|
||||
'documents': documents,
|
||||
};
|
||||
|
||||
final Map<String, String> apiHeaders = {
|
||||
'content-type': '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.
|
||||
Future<models.Document> getDocument({required String databaseId, required String collectionId, required String documentId, List<String>? queries}) async {
|
||||
|
||||
@@ -98,26 +98,6 @@ void main() {
|
||||
|
||||
});
|
||||
|
||||
test('test method createDocuments()', () async {
|
||||
final Map<String, dynamic> data = {
|
||||
'total': 5,
|
||||
'documents': [],};
|
||||
|
||||
|
||||
when(client.call(
|
||||
HttpMethod.post,
|
||||
)).thenAnswer((_) async => Response(data: data));
|
||||
|
||||
|
||||
final response = await databases.createDocuments(
|
||||
databaseId: '<DATABASE_ID>',
|
||||
collectionId: '<COLLECTION_ID>',
|
||||
documents: [],
|
||||
);
|
||||
expect(response, isA<models.DocumentList>());
|
||||
|
||||
});
|
||||
|
||||
test('test method getDocument()', () async {
|
||||
final Map<String, dynamic> data = {
|
||||
'\$id': '5e5ea5c16897e',
|
||||
|
||||
Reference in New Issue
Block a user