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

Commit 931611b

Browse files
author
Vincent (Wen Yu) Ge
committed
Update Database guide to conform to guidelines proposed in PR #229.
1 parent 0d12e98 commit 931611b

File tree

1 file changed

+51
-52
lines changed

1 file changed

+51
-52
lines changed

app/views/docs/databases.phtml

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<p>
22
The Databases Service allows you to store your application and users' data and fetch it using different supported queries.
3-
Using your Appwrite Databases, you can create multiple databases, organize your data into collections and documents using the Appwrite REST API. You can also use the Appwrite <a href="/docs/realtime">Realtime API</a> to subscribe to live changes in your collections and documents.
4-
In addition, the Databases Service provides built-in validation to check the integrity of your incoming data, custom indexing for query performance,
5-
as well as a flexible permissions mechanism to allow you to easily segment data between different users, teams, and roles.
3+
Using the Databases Service, you can create multiple databases and organize your data into collections and documents using Appwrite's REST API. You can also use the Appwrite <a href="/docs/realtime">Realtime API</a> to subscribe to live changes in your collections and documents.
4+
In addition, the Databases Service provides built-in validation to check the integrity of your incoming data, custom indexing for query performance, and a flexible permissions mechanism to easily segment data between different users, teams, and roles.
65
</p>
76

87
<h2><a href="/docs/databases#databases" id="databases">Create Your Databases</a></h2>
@@ -33,7 +32,7 @@
3332

3433
<h3><a href="/docs/databases#permissions" id="permissions">Permissions</a></h3>
3534
<p>
36-
Appwrite provides permissions to restrict access to documents at two levels, document and collection level. When a user has the appropriate type of <a href="/docs/permissions/">access permissions</a> granted at <b>either</b> the document or the collection level, they will be able to access or change the document. If the permission field is left empty, Client SDKs cannot access the document.
35+
Appwrite provides permissions to restrict access to documents at two levels, document and collection level. When a user has the appropriate <a href="/docs/permissions/">permission type</a> granted at <b>either</b> the document or the collection level, they will be able to access or change the document. If the permission field is left empty, Client SDKs cannot access the document.
3736
</p>
3837

3938
<h4>Document Level Permissions</h4>
@@ -55,46 +54,46 @@
5554
</thead>
5655
<tbody>
5756
<tr>
58-
<td>string</td>
57+
<td><code>string</code></td>
5958
<td>String attribute.</td>
6059
</tr>
6160
<tr>
62-
<td>integer</td>
61+
<td><code>integer</code></td>
6362
<td>Integer attribute.</td>
6463
</tr>
6564
<tr>
66-
<td>float</td>
65+
<td><code>float</code></td>
6766
<td>Float attribute.</td>
6867
</tr>
6968
<tr>
70-
<td>boolean</td>
69+
<td><code>boolean</code></td>
7170
<td>Boolean attribute.</td>
7271
</tr>
7372
<tr>
74-
<td>enum</td>
73+
<td><code>enum</code></td>
7574
<td>Enum attribute.</td>
7675
</tr>
7776
<tr>
78-
<td>ip</td>
77+
<td><code>ip</code></td>
7978
<td>IP address attribute for IPv4 and IPv6.</td>
8079
</tr>
8180
<tr>
82-
<td>email</td>
81+
<td><code>email</code></td>
8382
<td>Email address attribute.</td>
8483
</tr>
8584
<tr>
86-
<td>url</td>
85+
<td><code>url</code></td>
8786
<td>URL attribute.</td>
8887
</tr>
8988
</tbody>
9089
</table>
9190

9291
<p>
93-
If an attribute must be present in all documents, set it as <span class="tag">required</span>. If not, a <span class="tag">default</span> value might be handy. Additionally, decide if the attribute should be a primitive or array of values.
92+
If an attribute must be populated in all documents, set it as <code>required</code>. If not, a default value might be handy, but is not required. Additionally, decide if the attribute should be a primitive or an array of values.
9493
</p>
9594
<p>
96-
When adding or removing attributes, your requests are processed in the background, indicated by the attribute's <span class="tag">status</span>.
97-
Depending on your collection's size and other factors, this could take anywhere from a few seconds to a few minutes to complete. You are able to create a document while your attributes are still being processed, however you are not able to use the attributes on the documents until they are <span class="tag">available</span>
95+
When adding or removing attributes, your requests are processed in the background, indicated by the attribute's <code>status</code>.
96+
Depending on your collection's size and other factors, this could take anywhere from a few seconds to a few minutes to complete. You are able to create a document while your attributes are still being processed, but you are not able to use the attributes on the documents until their <code>status</code> becomes <code>available</code>.
9897
</p>
9998

10099
<h3><a href="/docs/databases#create-documents" id="create-documents">Create Documents</a></h3>
@@ -211,10 +210,10 @@ func main() async throws {
211210

212211
<div class="notice margin-top-large margin-bottom-large">
213212
<h4>Indexes Required</h4>
214-
<p>You can only query indexed attributes. You can easily add new indexes from both the Appwrite console or any of the <a href="/docs/sdks#server">server SDKs</a>. Appwrite uses this limitation to enforce optimized queries for maximum performance and scalability of your collection. You can learn more about it in the <a href="/docs/databases#indexes">Appwrite Indexes</a> section.</p>
213+
<p>You can only query indexed attributes. You can easily add new indexes from both your project's dashboard or any of the <a href="/docs/sdks#server">server SDKs</a>. Appwrite uses this limitation to enforce optimized queries for maximum performance and scalability of your collection. You can learn more about it in the <a href="/docs/databases#indexes">Appwrite Indexes</a> section.</p>
215214
</div>
216215
<p>
217-
To find specific documents in a collection, pass an array of query strings as a parameter to the <a href="/docs/server/databases#databasesListDocuments">listDocuments</a> endpoint. The SDKs provide a <b>Query</b> class to make query building simpler:
216+
To find specific documents in a collection, pass an array of query strings as a parameter to the <a href="/docs/server/databases#databasesListDocuments">List Documents</a> endpoint. The SDKs provide a <code>Query</code> class to make query building simpler:
218217
</p>
219218
<ul class="phases clear" data-ui-phases>
220219
<li>
@@ -339,74 +338,74 @@ func main() async throws{
339338
</thead>
340339
<tbody>
341340
<tr>
342-
<td>equal</td>
343-
<td>Query.equal("title", ["Iron Man"])</td>
341+
<td>Equal</td>
342+
<td><code>Query.equal("title", ["Iron Man"])</code></td>
344343
<td>Returns document if attribute is equal to any value in the provided array. Applies to any indexed attribute.</td>
345344
</tr>
346345
<tr>
347-
<td>notEqual</td>
348-
<td>Query.notEqual("title", ["Iron Man"])</td>
346+
<td>Not Equal</td>
347+
<td><code>Query.notEqual("title", ["Iron Man"])</code></td>
349348
<td>Returns document if attribute is not equal to any value in the provided array. Applies to any indexed attribute.</td>
350349
</tr>
351350
<tr>
352-
<td>lessThan</td>
353-
<td>Query.lessThan("score", 10)</td>
351+
<td>Less Than</td>
352+
<td><code>Query.lessThan("score", 10)</code></td>
354353
<td>Returns document if attribute is less than the provided value. Applies to any indexed attribute.</td>
355354
</tr>
356355
<tr>
357-
<td>lessThanEqual</td>
358-
<td>Query.lessThanEqual("score", 10)</td>
356+
<td>Less Than or Equal To</td>
357+
<td><code>Query.lessThanEqual("score", 10)</code></td>
359358
<td>Returns document if attribute is less than or equal to the provided value. Applies to any indexed attribute.</td>
360359
</tr>
361360
<tr>
362-
<td>greaterThan</td>
363-
<td>Query.greaterThan("score", 10)</td>
361+
<td>Greater Than</td>
362+
<td><code>Query.greaterThan("score", 10)</code></td>
364363
<td>Returns document if attribute is greater than the provided value. Applies to any indexed attribute.</td>
365364
</tr>
366365
<tr>
367-
<td>greaterThanEqual</td>
368-
<td>Query.greaterThanEqual("score", 10)</td>
366+
<td>Greater Than or Equal To</td>
367+
<td><code>Query.greaterThanEqual("score", 10)</code></td>
369368
<td>Returns document if attribute is greater than or equal to the provided value. Applies to any indexed attribute.</td>
370369
</tr>
371370
<tr>
372-
<td>search</td>
373-
<td>Query.search("text", "key words")</td>
371+
<td>Search</td>
372+
<td><code>Query.search("text", "key words")</code></td>
374373
<td>Searches string attributes for provided keywords. Applies to any string attribute with a full-text index.</td>
375374
</tr>
376375
<tr>
377-
<td>orderDesc</td>
378-
<td>Query.orderDesc("attribute")</td>
376+
<td>Order Descending</td>
377+
<td><code>Query.orderDesc("attribute")</code></td>
379378
<td>Orders results in descending order by attribute. Attribute must be indexed. Pass in an empty string to return in natural order.</td>
380379
</tr>
381380
<tr>
382-
<td>orderAsc</td>
383-
<td>Query.orderAsc("attribute")</td>
381+
<td>Order Ascending</td>
382+
<td><code>Query.orderAsc("attribute")</code></td>
384383
<td>Orders results in ascending order by attribute. Attribute must be indexed. Pass in an empty string to return in natural order.</td>
385384
</tr>
386385
<tr>
387-
<td>limit</td>
388-
<td>Query.limit(25)</td>
386+
<td>Limit</td>
387+
<td><code>Query.limit(25)</code></td>
389388
<td>Limits the number of results returned by the query. Used for <a href="/docs/pagination#offset-pagination" id="offset-pagination">pagination</a>.</td>
390389
</tr>
391390
<tr>
392-
<td>offset</td>
393-
<td>Query.offset(0)</td>
391+
<td>Offset</td>
392+
<td><code>Query.offset(0)</code></td>
394393
<td>Offset the results returned by skipping some of the results. Used for <a href="/docs/pagination#offset-pagination" id="offset-pagination">pagination</a>.</td>
395394
</tr>
396395
<tr>
397-
<td>cursorAfter</td>
398-
<td>Query.cursorAfter("62a7...f620")</td>
396+
<td>Cursor After</td>
397+
<td><code>Query.cursorAfter("62a7...f620")</code></td>
399398
<td>Places the cursor after the specified resource ID. Used for <a href="/docs/pagination#cursor-pagination" id="cursor-pagination">pagination</a>.</td>
400399
</tr>
401400
<tr>
402-
<td>cursorBefore</td>
403-
<td>Query.cursorBefore("62a7...a600")</td>
401+
<td>Cursor Before</td>
402+
<td><code>Query.cursorBefore("62a7...a600")</code></td>
404403
<td>Places the cursor before the specified resource ID. Used for <a href="/docs/pagination#cursor-pagination" id="cursor-pagination">pagination</a>.</td>
405404
</tr>
406405
</tbody>
407406
</table>
408407

409-
<p>Each query string is logically separated via AND. For OR logic, pass multiple values, separated by commas:</p>
408+
<p>Each query string is logically separated via <code>AND</code> operation. For <code>OR</code> operation, pass multiple values separated by commas:</p>
410409
<ul class="phases clear" data-ui-phases>
411410
<li>
412411
<h3>Web</h3>
@@ -515,15 +514,15 @@ func main() async throws {
515514
</li>
516515
</ul>
517516

518-
<p>When performing a query against multiple attributes, a single index with all query attributes is required. In the example above, a single index with <b>both</b> <span class="tag">title</span> and <span class="tag">year</span> is required.</p>
517+
<p>When performing a query against multiple attributes, a single index with all query attributes is required. In the example above, a single index with <b>both</b> <code>title</code> and <code>year</code> is required.</p>
519518

520519
<h2><a href="/docs/databases#indexes" id="indexes">Indexes</a></h2>
521520
<p>
522-
Indexes are used by Databases to quickly locate data without having to search through every document for results.
521+
Databases use indexes to quickly locate data without having to search through every document for matches.
523522
To ensure the best performance, Appwrite requires an index for every query.
524-
You can create an index by navigating to the <b>Indexes</b> tab of your collection or by using your favorite Server SDK. If you plan to query multiple attributes in a single query, you will need an index with <b>all</b> queried attributes.
523+
You can create an index by navigating to your collection's <b>Indexes</b> tab or by using your favorite Server SDK. If you plan to query multiple attributes in a single query, you will need an index with <b>all</b> queried attributes.
525524
</p>
526-
<p>It should be noted that Appwrite's database was designed to protect your queries from performing a full-table scan as this is a footgun and could cause catastrophic performance degradation as you scale up your Appwrite project.</p>
525+
<p>It should be noted that Appwrite's Databases Service is designed to protect your queries from performing a full-table scan, as this could cause catastrophic performance degradation as you scale up your Appwrite project.</p>
527526
<p>
528527
The following indexes are currently supported:
529528
</p>
@@ -536,15 +535,15 @@ func main() async throws {
536535
</thead>
537536
<tbody>
538537
<tr>
539-
<td>key</td>
538+
<td><code>key</code></td>
540539
<td>Plain Index to allow queries.</td>
541540
</tr>
542541
<tr>
543-
<td>unique</td>
542+
<td><code>unique</code></td>
544543
<td>Unique Index which not allows duplicates.</td>
545544
</tr>
546545
<tr>
547-
<td>fulltext</td>
546+
<td><code>fulltext</code></td>
548547
<td>For searching within string attributes</td>
549548
</tr>
550549
</tbody>
@@ -766,7 +765,7 @@ func main() async throws {
766765
</li>
767766
</ul>
768767

769-
<p>In the example above, the movies returned will be first sorted by title in ascending order, then sorted by year in descending order.</p>
768+
<p>In the example above, the movies returned will be first sorted by <code>title</code> in ascending order, then sorted by <code>year</code> in descending order.</p>
770769

771770
<h3><a href="/docs/databases#pagination" id="pagination">Pagination</a></h3>
772771
<p>Appwrite has full support for pagination to better optimize and scale up your applications built on Appwrite. Detailed documentation on pagination and how to implement it can be found on the <a href="/docs/pagination">pagination guide.</a></p>

0 commit comments

Comments
 (0)