@@ -56,230 +56,6 @@ To import documents using the Appwrite Console:
56
56
57
57
CSV imports run as background tasks. The Console displays a floating progress bar while the import is active.
58
58
59
- # Import documents using the API {% #import-api %}
60
-
61
- You can also trigger imports using the Appwrite API or SDKs.
62
-
63
- {% multicode %}
64
-
65
- ```http
66
- POST https://<REGION>.cloud.appwrite.io/v1/migrations/csv
67
- X-Appwrite-Project: "<PROJECT_ID>"
68
- Content-Type: application/json
69
-
70
- {
71
- "bucketId": "<BUCKET_ID>",
72
- "fileId": "<FILE_ID>",
73
- "resourceId": "<DATABASE_ID>:<COLLECTION_ID>"
74
- }
75
- ```
76
-
77
- ```server-nodejs
78
- const sdk = require('node-appwrite');
79
-
80
- // Init SDK
81
- const client = new sdk.Client();
82
- const migrations = new sdk.Migrations(client);
83
-
84
- client
85
- .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
86
- .setProject('<PROJECT_ID>') // Your project ID
87
- .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
88
- ;
89
-
90
- const promise = migrations.createCsvMigration('<BUCKET_ID>', '<FILE_ID>', '<DATABASE_ID>:<COLLECTION_ID>');
91
-
92
- promise.then(function (response) {
93
- console.log(response);
94
- }, function (error) {
95
- console.log(error);
96
- });
97
- ```
98
-
99
- ```deno
100
- import * as sdk from "https://deno.land/x/appwrite/mod.ts";
101
-
102
- // Init SDK
103
- let client = new sdk.Client();
104
- let migrations = new sdk.Migrations(client);
105
-
106
- client
107
- .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
108
- .setProject('<PROJECT_ID>') // Your project ID
109
- .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
110
- ;
111
-
112
- let promise = migrations.createCsvMigration('<BUCKET_ID>', '<FILE_ID>', '<DATABASE_ID>:<COLLECTION_ID>');
113
-
114
- promise.then(function (response) {
115
- console.log(response);
116
- }, function (error) {
117
- console.log(error);
118
- });
119
- ```
120
-
121
- ```php
122
- <?php
123
-
124
- use Appwrite\Client;
125
- use Appwrite\Services\Migrations;
126
-
127
- $client = new Client();
128
-
129
- $client
130
- ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
131
- ->setProject('<PROJECT_ID>') // Your project ID
132
- ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
133
- ;
134
-
135
- $migrations = new Migrations($client);
136
-
137
- $result = $migrations->createCsvMigration('<BUCKET_ID>', '<FILE_ID>', '<DATABASE_ID>:<COLLECTION_ID>');
138
- ```
139
-
140
- ```python
141
- from appwrite.client import Client
142
- from appwrite.services.migrations import Migrations
143
-
144
- client = Client()
145
-
146
- (client
147
- .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
148
- .set_project('<PROJECT_ID>') # Your project ID
149
- .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
150
- )
151
-
152
- migrations = Migrations(client)
153
-
154
- result = migrations.create_csv_migration('<BUCKET_ID>', '<FILE_ID>', '<DATABASE_ID>:<COLLECTION_ID>')
155
- ```
156
-
157
- ```ruby
158
- require 'Appwrite'
159
-
160
- include Appwrite
161
-
162
- client = Client.new
163
- .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
164
- .set_project('<PROJECT_ID>') # Your project ID
165
- .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
166
-
167
- migrations = Migrations.new(client)
168
-
169
- response = migrations.create_csv_migration(bucket_id: '<BUCKET_ID>', file_id: '<FILE_ID>', resource_id: '<DATABASE_ID>:<COLLECTION_ID>')
170
-
171
- puts response.inspect
172
- ```
173
-
174
- ```csharp
175
- using Appwrite;
176
- using Appwrite.Services;
177
- using Appwrite.Models;
178
-
179
- var client = new Client()
180
- .SetEndPoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
181
- .SetProject("<PROJECT_ID>") // Your project ID
182
- .SetKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
183
-
184
- var migrations = new Migrations(client);
185
-
186
- var result = await migrations.CreateCsvMigration(
187
- bucketId: "<BUCKET_ID>",
188
- fileId: "<FILE_ID>",
189
- resourceId: "<DATABASE_ID>:<COLLECTION_ID>"
190
- );
191
- ```
192
-
193
- ```dart
194
- import 'package:dart_appwrite/dart_appwrite.dart';
195
-
196
- void main() {
197
- Client client = Client();
198
- Migrations migrations = Migrations(client);
199
-
200
- client
201
- .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
202
- .setProject('<PROJECT_ID>') // Your project ID
203
- .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
204
- ;
205
-
206
- Future result = migrations.createCsvMigration(
207
- bucketId: '<BUCKET_ID>',
208
- fileId: '<FILE_ID>',
209
- resourceId: '<DATABASE_ID>:<COLLECTION_ID>',
210
- );
211
-
212
- result.then((response) {
213
- print(response);
214
- }).catchError((error) {
215
- print(error.response);
216
- });
217
- }
218
- ```
219
-
220
- ```kotlin
221
- import io.appwrite.Client
222
- import io.appwrite.services.Migrations
223
-
224
- val client = Client(context)
225
- .setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
226
- .setProject("<PROJECT_ID>") // Your project ID
227
- .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
228
-
229
- val migrations = Migrations(client)
230
-
231
- val response = migrations.createCsvMigration(
232
- bucketId = "<BUCKET_ID>",
233
- fileId = "<FILE_ID>",
234
- resourceId = "<DATABASE_ID>:<COLLECTION_ID>"
235
- )
236
- ```
237
-
238
- ```java
239
- import io.appwrite.Client;
240
- import io.appwrite.coroutines.CoroutineCallback;
241
- import io.appwrite.services.Migrations;
242
-
243
- Client client = new Client()
244
- .setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
245
- .setProject("<PROJECT_ID>") // Your project ID
246
- .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
247
-
248
- Migrations migrations = new Migrations(client);
249
-
250
- migrations.createCsvMigration(
251
- "<BUCKET_ID>",
252
- "<FILE_ID>",
253
- "<DATABASE_ID>:<COLLECTION_ID>",
254
- new CoroutineCallback<>((result, error) -> {
255
- if (error != null) {
256
- error.printStackTrace();
257
- return;
258
- }
259
- System.out.println(result);
260
- })
261
- );
262
- ```
263
-
264
- ```swift
265
- import Appwrite
266
-
267
- let client = Client()
268
- .setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
269
- .setProject("<PROJECT_ID>") // Your project ID
270
- .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
271
-
272
- let migrations = Migrations(client)
273
-
274
- let migration = try await migrations.createCsvMigration(
275
- bucketId: "<BUCKET_ID>",
276
- fileId: "<FILE_ID>",
277
- resourceId: "<DATABASE_ID>:<COLLECTION_ID>"
278
- )
279
- ```
280
-
281
- {% /multicode %}
282
-
283
59
# Additional resources {% #additional-resources %}
284
60
285
61
- [Appwrite CLI for Migrations](/docs/command-line-tools)
0 commit comments