Skip to content
This repository was archived by the owner on Sep 29, 2023. It is now read-only.

Commit 47d8102

Browse files
Merge pull request #211 from appwrite/0.15.x
0.15.x
2 parents ce71489 + b672b4c commit 47d8102

File tree

10 files changed

+423
-290
lines changed

10 files changed

+423
-290
lines changed

app/views/docs/command-line.phtml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ brew install --HEAD appwrite</code></pre>
242242
<td>The functions command allows you view, create and manage your Cloud Functions</td>
243243
</tr>
244244
<tr>
245-
<td>database</td>
246-
<td>The database command allows you to create structured collections of documents, query and filter lists of documents</td>
245+
<td>databases</td>
246+
<td>The databases command allows you to create structured collections of documents, query and filter lists of documents</td>
247247
</tr>
248248
<tr>
249249
<td>health</td>
@@ -286,13 +286,13 @@ brew install --HEAD appwrite</code></pre>
286286
<p>To get a list of all your collections, you can use the `listCollections` command. To successfully view the list, make sure your API key is granted with the scope "collections.read".</p>
287287

288288
<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
289-
<pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite database listCollections</code></pre>
289+
<pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite databases listCollections</code></pre>
290290
</div>
291291

292292
<p>If you wish to parse the output from the CLI, you can request the CLI output in JSON format using the <span class="tag">--json</span> flag</p>
293293

294294
<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
295-
<pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite database listCollections --json</code></pre>
295+
<pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite databases listCollections --json</code></pre>
296296
</div>
297297
<!-- Attach image of output -->
298298

@@ -301,15 +301,15 @@ brew install --HEAD appwrite</code></pre>
301301
<p>To get more information on a particular collection, you can make use of the `getCollection` command and pass in the `collectionId`. To successfully fetch the collection, make sure your API key is granted with the scope "collections.read".</p>
302302

303303
<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
304-
<pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite database getCollection --collectionId 5ff468cfa32a0</code></pre>
304+
<pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite databases getCollection --collectionId 5ff468cfa32a0</code></pre>
305305
</div>
306306

307307
<p><b>Create Document</b></p>
308308

309309
<p>To create a new document in an existing collection, use the `createDocument` command.</p>
310310

311311
<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
312-
<pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite database createDocument --collectionId <ID> --documentId 'unique()' --data '{ "Name": "Iron Man" }' --read role:all team:abc</code></pre>
312+
<pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite databases createDocument --collectionId <ID> --documentId 'unique()' --data '{ "Name": "Iron Man" }' --read role:all team:abc</code></pre>
313313
</div>
314314

315315
<h3><a href="/docs/command-line#configuration" id="configuration">Configuration</a></h3>

app/views/docs/database.phtml renamed to app/views/docs/databases.phtml

Lines changed: 89 additions & 61 deletions
Large diffs are not rendered by default.

app/views/docs/functions.phtml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -546,14 +546,17 @@ $image = new View(__DIR__.'/../general/image.phtml');
546546
<li>
547547
<h3>Web</h3>
548548
<div class="ide margin-bottom" data-lang="javascript" data-lang-label="Web SDK">
549-
<pre class="line-numbers"><code class="prism language-javascript" data-prism>const sdk = new Appwrite();
549+
<pre class="line-numbers"><code class="prism language-javascript" data-prism>import { Client, Functions } from "appwrite";
550550

551-
sdk
552-
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
553-
.setProject('5df5acd0d48c2') // Your project ID
554-
;
551+
const client = new Client();
552+
553+
client
554+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1')
555+
.setProject('[PROJECT_ID]');
555556

556-
let promise = sdk.functions.createExecution('[FUNCTION_ID]');
557+
const databases = new Databases(client, '[DATABASE_ID]');
558+
559+
let promise = functions.createExecution('[FUNCTION_ID]');
557560

558561
promise.then(function (response) {
559562
console.log(response); // Success
@@ -650,7 +653,7 @@ class MainActivity : AppCompatActivity() {
650653

651654
<p>When triggering a Cloud Function execution from the client, your users will be limited to a specific amount of execution per minute to make sure your Appwrite server is not being abused. The default limit is 60 calls per 1 minute. You can edit this limit using the server <a href="/docs/environment-variables#functions">environment variables</a>.</p>
652655

653-
<p>The response size of a Cloud Function is limited to 1MB. Reponses larger than 1MB should be handled using Appwrite's Database or Storage service.</p>
656+
<p>The response size of a Cloud Function is limited to 1MB. Reponses larger than 1MB should be handled using Appwrite's Databases or Storage service.</p>
654657

655658
<h2><a href="/docs/functions#ignoreFiles" id="ignoreFiles">Ignore Files</a></h2>
656659

@@ -685,7 +688,7 @@ class MainActivity : AppCompatActivity() {
685688

686689
<p>Appwrite provides multiple code runtimes to execute your custom functions. Each runtime uses a Docker image tied to a specific language version to provide a safe, isolated playground to run your team's code.</p>
687690

688-
<p>Below is a list of supported Cloud Functions runtimes. The Appwrite team continually adds support for new runtimes. You can easily change which runtimes your Appwrite setup supports by editing your server <a href="/docs/environment-variables#functions">environment variables</a>.</p>
691+
<p>Below is a list of supported Cloud Functions runtimes. The Appwrite team continually adds support for new runtimes.</p>
689692

690693
<table cellspacing="0" cellpadding="0" border="0" class="full margin-bottom-large">
691694
<thead>
@@ -708,6 +711,8 @@ class MainActivity : AppCompatActivity() {
708711
</tbody>
709712
</table>
710713

714+
<p>By default, the following runtimes are enabled: "node-16.0, php-8.0, python-3.9, ruby-3.0". To enable or disable runtimes, you can edit the <span class="tag">_APP_FUNCTIONS_RUNTIMES</span> <a href="/docs/functions#environmentVariables">environment variable</a>.</p>
715+
711716
<h2><a href="/docs/functions#environmentVariables" id="environmentVariables">Environment Variables</a></h2>
712717

713718
<p>Environment variables supplied by Appwrite in addition to your own defined environment variables that you can access from your function code. These variables give you information about your execution runtime environment.</p>
@@ -744,6 +749,12 @@ class MainActivity : AppCompatActivity() {
744749
</td>
745750
<td>Either 'event' when triggered by one of the selected scopes, 'http' when triggered by an HTTP request or the Appwrite Console, or 'schedule' when triggered by the cron schedule.</td>
746751
</tr>
752+
<tr>
753+
<td>
754+
_APP_FUNCTIONS_RUNTIMES
755+
</td>
756+
<td>Enables function runtimes. Pass a list of runtime names separated by a comma, for example "node-16.0,php-8.0,python-3.9,ruby-3.0".</td>
757+
</tr>
747758
<tr>
748759
<td>
749760
APPWRITE_FUNCTION_RUNTIME_NAME

app/views/docs/index.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ $cols = [
5858
<li><a href="/docs/client/account<?php echo $this->escape($clientSDK); ?>">Account</a></li>
5959
<li><a href="/docs/server/users<?php echo $this->escape($serverSDK); ?>">Users</a></li>
6060
<li><a href="/docs/client/teams<?php echo $this->escape($clientSDK); ?>">Teams</a></li>
61-
<li><a href="/docs/client/database<?php echo $this->escape($clientSDK); ?>">Database</a></li>
61+
<li><a href="/docs/client/databases<?php echo $this->escape($clientSDK); ?>">Databases</a></li>
6262
<li><a href="/docs/client/storage<?php echo $this->escape($clientSDK); ?>">Storage</a></li>
6363
<li><a href="/docs/client/functions<?php echo $this->escape($serverSDK); ?>">Functions</a></li>
6464
<li><a href="/docs/client/locale<?php echo $this->escape($clientSDK); ?>">Localization</a></li>
@@ -72,7 +72,7 @@ $cols = [
7272

7373
<ul class="margin-bottom">
7474
<li><a href="/docs/realtime">Realtime</a></li>
75-
<li><a href="/docs/database">Database</a></li>
75+
<li><a href="/docs/databases">Databases</a></li>
7676
<li><a href="/docs/storage">Storage</a></li>
7777
<li><a href="/docs/functions">Functions</a></li>
7878
<li><a href="/docs/keys">API Keys</a></li>

app/views/docs/pagination.phtml

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313
<li>
1414
<h3>Web</h3>
1515
<div class="ide" data-lang="javascript" data-lang-label="Web SDK">
16-
<pre class="line-numbers"><code class="prism language-javascript" data-prism>// Page 1
17-
const page1 = await sdk.database.listDocuments('movies', [], 25, 0);
16+
<pre class="line-numbers"><code class="prism language-javascript" data-prism>import { Databases } from "appwrite";
17+
const databases = new Databases(client, "[DATABASE_ID]"); // 'client' comes from setup
18+
19+
// Page 1
20+
const page1 = await databases.listDocuments('movies', [], 25, 0);
21+
1822
// Page 2
19-
const page2 = await sdk.database.listDocuments('movies', [], 25, 25);
23+
const page2 = await databases.listDocuments('movies', [], 25, 25);
2024
</code></pre>
2125
</div>
2226
</li>
@@ -27,13 +31,13 @@ const page2 = await sdk.database.listDocuments('movies', [], 25, 25);
2731

2832
void main() async {
2933
final client = Client();
30-
final database = Database(client);
34+
final databases = Databases(client, databaseId: '[DATABASE_ID]');
3135
try {
32-
final page1 = await database.listDocuments(
36+
final page1 = await databases.listDocuments(
3337
collectionId: 'movies',
3438
limit: 25,
3539
offset: 0);
36-
final page2 = await database.listDocuments(
40+
final page2 = await databases.listDocuments(
3741
collectionId: 'movies',
3842
limit: 25,
3943
offset: 25);
@@ -52,7 +56,7 @@ import android.os.Bundle
5256
import kotlinx.coroutines.GlobalScope
5357
import kotlinx.coroutines.launch
5458
import io.appwrite.Client
55-
import io.appwrite.services.Database
59+
import io.appwrite.services.Databases
5660
import io.appwrite.Query
5761

5862
class MainActivity : AppCompatActivity() {
@@ -64,16 +68,16 @@ class MainActivity : AppCompatActivity() {
6468
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
6569
.setProject("5df5acd0d48c2") // Your project ID
6670

67-
val database = Database(client)
71+
val databases = Databases(client, "[DATABASE_ID]")
6872

6973
GlobalScope.launch {
70-
val page1 = database.listDocuments(
74+
val page1 = databases.listDocuments(
7175
collectionId = "[COLLECTION_ID]",
7276
limit = 25,
7377
offset = 0,
7478
)
7579

76-
val page2 = database.listDocuments(
80+
val page2 = databases.listDocuments(
7781
collectionId = "[COLLECTION_ID]",
7882
limit = 25,
7983
offset = 25,
@@ -93,17 +97,17 @@ func main() async throws {
9397
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
9498
.setProject("my_project") // Your project ID
9599

96-
let database = Database(client)
100+
let databases = Databases(client, "[DATABASE_ID]")
97101
// Page 1
98-
var list = try await database.listDocuments(
102+
var list = try await databases.listDocuments(
99103
collectionId: "[COLLECTION_ID]",
100104
limit: 25,
101105
offset: 0
102106
)
103107
print(list.toMap())
104108

105109
// Page 2
106-
list = try await database.listDocuments(
110+
list = try await databases.listDocuments(
107111
collectionId: "[COLLECTION_ID]",
108112
limit: 25,
109113
offset: 25
@@ -129,12 +133,15 @@ func main() async throws {
129133
<li>
130134
<h3>Web</h3>
131135
<div class="ide" data-lang="javascript" data-lang-label="Web SDK">
132-
<pre class="line-numbers"><code class="prism language-javascript" data-prism>// Page 1
133-
const page1 = await sdk.database.listDocuments('movies', [], 25, 0);
136+
<pre class="line-numbers"><code class="prism language-javascript" data-prism>import { Databases } from "appwrite";
137+
const databases = new Databases(client, "[DATABASE_ID]"); // 'client' comes from setup
138+
139+
// Page 1
140+
const page1 = await databases.listDocuments('movies', [], 25, 0);
134141
const lastId = results.documents[results.documents.length - 1].$id;
135142

136143
// Page 2
137-
const page2 = await sdk.database.listDocuments('movies', [], 25, 0, lastId);
144+
const page2 = await databases.listDocuments('movies', [], 25, 0, lastId);
138145
</code></pre>
139146
</div>
140147
</li>
@@ -145,15 +152,15 @@ const page2 = await sdk.database.listDocuments('movies', [], 25, 0, lastId);
145152

146153
void main() async {
147154
final client = Client();
148-
final database = Database(client);
155+
final databases = Databases(client, databaseId: '[DATABASE_ID]');
149156
try {
150-
final page1 = await database.listDocuments(
157+
final page1 = await databases.listDocuments(
151158
collectionId: 'movies',
152159
limit: 25);
153160
final lastId = page1.documents[page1.documents.length - 1].$id;
154161

155162
// Page 2
156-
final page2 = await database.listDocuments(
163+
final page2 = await databases.listDocuments(
157164
collectionId: 'movies',
158165
cursor: lastId);
159166
} on AppwriteException catch(e) {
@@ -171,7 +178,7 @@ import android.os.Bundle
171178
import kotlinx.coroutines.GlobalScope
172179
import kotlinx.coroutines.launch
173180
import io.appwrite.Client
174-
import io.appwrite.services.Database
181+
import io.appwrite.services.Databases
175182
import io.appwrite.Query
176183

177184
class MainActivity : AppCompatActivity() {
@@ -183,17 +190,17 @@ class MainActivity : AppCompatActivity() {
183190
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
184191
.setProject("5df5acd0d48c2") // Your project ID
185192

186-
val database = Database(client)
193+
val databases = Databases(client, "[DATABASE_ID]")
187194

188195
GlobalScope.launch {
189-
val page1 = database.listDocuments(
196+
val page1 = databases.listDocuments(
190197
collectionId = "[COLLECTION_ID]",
191198
limit = 25,
192199
)
193200
val lastId = page1.documents[page1.documents.length - 1].$id
194201

195202
// Page 2
196-
val page2 = database.listDocuments(
203+
val page2 = databases.listDocuments(
197204
collectionId = "[COLLECTION_ID]",
198205
cursor = lastId,
199206
)
@@ -212,18 +219,18 @@ func main() async throws {
212219
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
213220
.setProject("my_project") // Your project ID
214221

215-
let database = Database(client)
222+
let databases = Databases(client, "[DATABASE_ID]")
216223

217224
// Page 1
218-
var list = try await database.listDocuments(
225+
var list = try await databases.listDocuments(
219226
collectionId: "[COLLECTION_ID]",
220227
limit: 25,
221228
)
222229

223230
let lastId = list.documents[list.documents.count - 1].$id
224231

225232
// Page 2
226-
list = try await database.listDocuments(
233+
list = try await databases.listDocuments(
227234
collectionId: "[COLLECTION_ID]",
228235
cursor: lastId,
229236
)

app/views/docs/permissions.phtml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,17 @@
112112
<p>In the following example, we are creating a document that can be read by everyone and only be edited, or deleted by a user with a UID <span class="tag">user:5c1f88b42259e</span>.</p>
113113

114114
<div class="ide" data-lang="javascript" data-lang-label="Web SDK">
115-
<pre class="line-numbers"><code class="prism language-javascript" data-prism>const sdk = new Appwrite();
115+
<pre class="line-numbers"><code class="prism language-javascript" data-prism>import { Client, Databases } from "appwrite";
116+
117+
const client = new Client();
116118

117-
sdk
118-
.setProject('')
119-
;
119+
client
120+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1')
121+
.setProject('[PROJECT_ID]');
120122

121-
let promise = sdk.database.createDocument(
123+
const databases = new Databases(client, '[DATABASE_ID]');
124+
125+
let promise = databases.createDocument(
122126
'[COLLECTION_ID]',
123127
{'actorName': 'Chris Evans', 'height': 183},
124128
['role:all'], // Anyone can view this document
@@ -139,13 +143,17 @@ promise.then(function (response) {
139143
<p>In the following example, we are creating a document that can be read-only by members of <span class="tag">team:5c1f88b87435e</span> and can only be edited, or deleted by members of the same team that possesses the role <span class="tag">owner</span>.</p>
140144

141145
<div class="ide" data-lang="javascript" data-lang-label="Web SDK">
142-
<pre class="line-numbers"><code class="prism language-javascript" data-prism>const sdk = new Appwrite();
146+
<pre class="line-numbers"><code class="prism language-javascript" data-prism>import { Client, Databases } from "appwrite";
147+
148+
const client = new Client();
149+
150+
client
151+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1')
152+
.setProject('[PROJECT_ID]');
143153

144-
sdk
145-
.setProject('')
146-
;
154+
const databases = new Databases(client, '[DATABASE_ID]');
147155

148-
let promise = sdk.database.createDocument(
156+
let promise = databases.createDocument(
149157
'[COLLECTION_ID]',
150158
{'actorName': 'Chris Evans', 'height': 183},
151159
['team:5c1f88b87435e'], // The user must be a team member to grant this permission

0 commit comments

Comments
 (0)