Skip to content
This repository was archived by the owner on Sep 29, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ff18bd4
update pagination guide
Jun 21, 2022
b35cfe0
Rename all to reference to databases service
Jun 22, 2022
86313fe
Rename all to reference to databases service in CLI
Jun 22, 2022
0601cc8
update realtime channel
Jun 22, 2022
8d7e828
update index links to database
Jun 22, 2022
df432be
fix: databases link
TorstenDittmann Jun 24, 2022
b4516f1
rebase on 0.15.x changes
Jun 24, 2022
1a15810
Add docs for activating and disabling function runtimes
Jun 25, 2022
444c1fb
Migrate to new web syntax
Meldiron Jun 26, 2022
b3cd345
Docs improvements
Meldiron Jun 26, 2022
2a7158b
Update app/views/docs/storage.phtml
gewenyu99 Jun 27, 2022
e7ecc2c
Merge pull request #204 from appwrite/database-layers
gewenyu99 Jun 27, 2022
b221950
fix: add Parsedown
TorstenDittmann Jun 28, 2022
dd7ed63
Merge branch '0.15.x' of https://github.com/appwrite/docs into 0.15.x
TorstenDittmann Jun 28, 2022
b81ffd0
Merge pull request #207 from appwrite/document-runtime-env
TorstenDittmann Jun 28, 2022
9834085
Merge branch '0.15.x' of https://github.com/appwrite/docs into feat-u…
TorstenDittmann Jun 28, 2022
81ba9b2
Merge pull request #206 from appwrite/feat-upgrade-web-syntax
TorstenDittmann Jun 28, 2022
7d57ac4
fix database examples
lohanidamodar Jun 28, 2022
31a9e4b
Merge pull request #209 from appwrite/fix-database-code-examples
TorstenDittmann Jun 28, 2022
3c0c47e
Merge branch 'main' of https://github.com/appwrite/docs into 0.15.x
TorstenDittmann Jun 28, 2022
b672b4c
fix: typo on databases
TorstenDittmann Jun 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions app/views/docs/command-line.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ brew install --HEAD appwrite</code></pre>
<td>The functions command allows you view, create and manage your Cloud Functions</td>
</tr>
<tr>
<td>database</td>
<td>The database command allows you to create structured collections of documents, query and filter lists of documents</td>
<td>databases</td>
<td>The databases command allows you to create structured collections of documents, query and filter lists of documents</td>
</tr>
<tr>
<td>health</td>
Expand Down Expand Up @@ -286,13 +286,13 @@ brew install --HEAD appwrite</code></pre>
<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>

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

<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>

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

Expand All @@ -301,15 +301,15 @@ brew install --HEAD appwrite</code></pre>
<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>

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

<p><b>Create Document</b></p>

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

<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
<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>
<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>
</div>

<h3><a href="/docs/command-line#configuration" id="configuration">Configuration</a></h3>
Expand Down
150 changes: 89 additions & 61 deletions app/views/docs/database.phtml → app/views/docs/databases.phtml

Large diffs are not rendered by default.

27 changes: 19 additions & 8 deletions app/views/docs/functions.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -546,14 +546,17 @@ $image = new View(__DIR__.'/../general/image.phtml');
<li>
<h3>Web</h3>
<div class="ide margin-bottom" data-lang="javascript" data-lang-label="Web SDK">
<pre class="line-numbers"><code class="prism language-javascript" data-prism>const sdk = new Appwrite();
<pre class="line-numbers"><code class="prism language-javascript" data-prism>import { Client, Functions } from "appwrite";

sdk
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
const client = new Client();

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1')
.setProject('[PROJECT_ID]');

let promise = sdk.functions.createExecution('[FUNCTION_ID]');
const databases = new Databases(client, '[DATABASE_ID]');

let promise = functions.createExecution('[FUNCTION_ID]');

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

<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>

<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>
<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>

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

Expand Down Expand Up @@ -685,7 +688,7 @@ class MainActivity : AppCompatActivity() {

<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>

<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>
<p>Below is a list of supported Cloud Functions runtimes. The Appwrite team continually adds support for new runtimes.</p>

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

<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>

<h2><a href="/docs/functions#environmentVariables" id="environmentVariables">Environment Variables</a></h2>

<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>
Expand Down Expand Up @@ -744,6 +749,12 @@ class MainActivity : AppCompatActivity() {
</td>
<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>
</tr>
<tr>
<td>
_APP_FUNCTIONS_RUNTIMES
</td>
<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>
</tr>
<tr>
<td>
APPWRITE_FUNCTION_RUNTIME_NAME
Expand Down
4 changes: 2 additions & 2 deletions app/views/docs/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ $cols = [
<li><a href="/docs/client/account<?php echo $this->escape($clientSDK); ?>">Account</a></li>
<li><a href="/docs/server/users<?php echo $this->escape($serverSDK); ?>">Users</a></li>
<li><a href="/docs/client/teams<?php echo $this->escape($clientSDK); ?>">Teams</a></li>
<li><a href="/docs/client/database<?php echo $this->escape($clientSDK); ?>">Database</a></li>
<li><a href="/docs/client/databases<?php echo $this->escape($clientSDK); ?>">Databases</a></li>
<li><a href="/docs/client/storage<?php echo $this->escape($clientSDK); ?>">Storage</a></li>
<li><a href="/docs/client/functions<?php echo $this->escape($serverSDK); ?>">Functions</a></li>
<li><a href="/docs/client/locale<?php echo $this->escape($clientSDK); ?>">Localization</a></li>
Expand All @@ -72,7 +72,7 @@ $cols = [

<ul class="margin-bottom">
<li><a href="/docs/realtime">Realtime</a></li>
<li><a href="/docs/database">Database</a></li>
<li><a href="/docs/databases">Databases</a></li>
<li><a href="/docs/storage">Storage</a></li>
<li><a href="/docs/functions">Functions</a></li>
<li><a href="/docs/keys">API Keys</a></li>
Expand Down
59 changes: 33 additions & 26 deletions app/views/docs/pagination.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
<li>
<h3>Web</h3>
<div class="ide" data-lang="javascript" data-lang-label="Web SDK">
<pre class="line-numbers"><code class="prism language-javascript" data-prism>// Page 1
const page1 = await sdk.database.listDocuments('movies', [], 25, 0);
<pre class="line-numbers"><code class="prism language-javascript" data-prism>import { Databases } from "appwrite";
const databases = new Databases(client, "[DATABASE_ID]"); // 'client' comes from setup

// Page 1
const page1 = await databases.listDocuments('movies', [], 25, 0);

// Page 2
const page2 = await sdk.database.listDocuments('movies', [], 25, 25);
const page2 = await databases.listDocuments('movies', [], 25, 25);
</code></pre>
</div>
</li>
Expand All @@ -27,13 +31,13 @@ const page2 = await sdk.database.listDocuments('movies', [], 25, 25);

void main() async {
final client = Client();
final database = Database(client);
final databases = Databases(client, databaseId: '[DATABASE_ID]');
try {
final page1 = await database.listDocuments(
final page1 = await databases.listDocuments(
collectionId: 'movies',
limit: 25,
offset: 0);
final page2 = await database.listDocuments(
final page2 = await databases.listDocuments(
collectionId: 'movies',
limit: 25,
offset: 25);
Expand All @@ -52,7 +56,7 @@ import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Database
import io.appwrite.services.Databases
import io.appwrite.Query

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

val database = Database(client)
val databases = Databases(client, "[DATABASE_ID]")

GlobalScope.launch {
val page1 = database.listDocuments(
val page1 = databases.listDocuments(
collectionId = "[COLLECTION_ID]",
limit = 25,
offset = 0,
)

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

let database = Database(client)
let databases = Databases(client, "[DATABASE_ID]")
// Page 1
var list = try await database.listDocuments(
var list = try await databases.listDocuments(
collectionId: "[COLLECTION_ID]",
limit: 25,
offset: 0
)
print(list.toMap())

// Page 2
list = try await database.listDocuments(
list = try await databases.listDocuments(
collectionId: "[COLLECTION_ID]",
limit: 25,
offset: 25
Expand All @@ -129,12 +133,15 @@ func main() async throws {
<li>
<h3>Web</h3>
<div class="ide" data-lang="javascript" data-lang-label="Web SDK">
<pre class="line-numbers"><code class="prism language-javascript" data-prism>// Page 1
const page1 = await sdk.database.listDocuments('movies', [], 25, 0);
<pre class="line-numbers"><code class="prism language-javascript" data-prism>import { Databases } from "appwrite";
const databases = new Databases(client, "[DATABASE_ID]"); // 'client' comes from setup

// Page 1
const page1 = await databases.listDocuments('movies', [], 25, 0);
const lastId = results.documents[results.documents.length - 1].$id;

// Page 2
const page2 = await sdk.database.listDocuments('movies', [], 25, 0, lastId);
const page2 = await databases.listDocuments('movies', [], 25, 0, lastId);
</code></pre>
</div>
</li>
Expand All @@ -145,15 +152,15 @@ const page2 = await sdk.database.listDocuments('movies', [], 25, 0, lastId);

void main() async {
final client = Client();
final database = Database(client);
final databases = Databases(client, databaseId: '[DATABASE_ID]');
try {
final page1 = await database.listDocuments(
final page1 = await databases.listDocuments(
collectionId: 'movies',
limit: 25);
final lastId = page1.documents[page1.documents.length - 1].$id;

// Page 2
final page2 = await database.listDocuments(
final page2 = await databases.listDocuments(
collectionId: 'movies',
cursor: lastId);
} on AppwriteException catch(e) {
Expand All @@ -171,7 +178,7 @@ import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Database
import io.appwrite.services.Databases
import io.appwrite.Query

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

val database = Database(client)
val databases = Databases(client, "[DATABASE_ID]")

GlobalScope.launch {
val page1 = database.listDocuments(
val page1 = databases.listDocuments(
collectionId = "[COLLECTION_ID]",
limit = 25,
)
val lastId = page1.documents[page1.documents.length - 1].$id

// Page 2
val page2 = database.listDocuments(
val page2 = databases.listDocuments(
collectionId = "[COLLECTION_ID]",
cursor = lastId,
)
Expand All @@ -212,18 +219,18 @@ func main() async throws {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("my_project") // Your project ID

let database = Database(client)
let databases = Databases(client, "[DATABASE_ID]")

// Page 1
var list = try await database.listDocuments(
var list = try await databases.listDocuments(
collectionId: "[COLLECTION_ID]",
limit: 25,
)

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

// Page 2
list = try await database.listDocuments(
list = try await databases.listDocuments(
collectionId: "[COLLECTION_ID]",
cursor: lastId,
)
Expand Down
28 changes: 18 additions & 10 deletions app/views/docs/permissions.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,17 @@
<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>

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

const client = new Client();

sdk
.setProject('')
;
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1')
.setProject('[PROJECT_ID]');

let promise = sdk.database.createDocument(
const databases = new Databases(client, '[DATABASE_ID]');

let promise = databases.createDocument(
'[COLLECTION_ID]',
{'actorName': 'Chris Evans', 'height': 183},
['role:all'], // Anyone can view this document
Expand All @@ -139,13 +143,17 @@ promise.then(function (response) {
<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>

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

const client = new Client();

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1')
.setProject('[PROJECT_ID]');

sdk
.setProject('')
;
const databases = new Databases(client, '[DATABASE_ID]');

let promise = sdk.database.createDocument(
let promise = databases.createDocument(
'[COLLECTION_ID]',
{'actorName': 'Chris Evans', 'height': 183},
['team:5c1f88b87435e'], // The user must be a team member to grant this permission
Expand Down
Loading