Skip to content

Commit 5fca01d

Browse files
Simran-BCircleCI
andauthored
Fix/improve interface examples for Concepts > Documents (#716)
* Add missing space * Fix links * Split Schema Validation examples into enabling and removing a schema * Change example name * Remove boldness * Unify CIRCLECI.md params * [skip ci] Automatic commit of generated files from CircleCI * Fix references --------- Co-authored-by: CircleCI <[email protected]>
1 parent 1af42a7 commit 5fca01d

File tree

14 files changed

+377
-100
lines changed

14 files changed

+377
-100
lines changed

CIRCLECI.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ or for multiple versions.
123123
| string | `workflow` | `generate` |
124124
| string | `arangodb-3_10` | [Upstream reference](#upstream-references) for 3.10 |
125125
| string | `arangodb-3_11` | [Upstream reference](#upstream-references) for 3.11 |
126+
| string | `arangodb-3_12` | [Upstream reference](#upstream-references) for 3.12 |
126127
| string | `generators` | `examples` |
127128
| boolean | `commit-generated` | `true` |
128129
| string | `deploy-url` | `deploy-preview-{PR_NUMBER}` |

site/content/3.11/concepts/data-structure/collections.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ in the _JavaScript API_ for details.
217217
curl -d '{"name":"coll"}' http://localhost:8529/_db/mydb/_api/collection
218218
```
219219

220-
See the [`POST /_db/{database-name}/_api/collection`](../../develop/http-api/databases.md#create-a-database)
220+
See the [`POST /_db/{database-name}/_api/collection`](../../develop/http-api/collections.md#create-a-collection)
221221
endpoint in the _HTTP API_ for details.
222222
{{< /tab >}}
223223

@@ -399,7 +399,7 @@ in the _JavaScript API_ for details.
399399
curl http://localhost:8529/_db/mydb/_api/collection
400400
```
401401

402-
See the [`GET /_db/{database-name}/_api/collection`](../../develop/http-api/collections.md#get-the-collection-information)
402+
See the [`GET /_db/{database-name}/_api/collection`](../../develop/http-api/collections.md#list-all-collections)
403403
endpoint in the _HTTP API_ for details.
404404
{{< /tab >}}
405405

site/content/3.11/concepts/data-structure/documents/computed-values.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ curl -XPUT -d '{"computedValues":[{"name":"title","expression":"RETURN \"TBA\"",
146146
```
147147

148148
See the [`PUT /_db/{database-name}/_api/collection/{collection-name}/properties`](../../../develop/http-api/collections.md#change-the-properties-of-a-collection)
149-
endpoint in the _HTTP API_for details.
149+
endpoint in the _HTTP API_ for details.
150150
{{< /tab >}}
151151

152152
{{< tab "JavaScript" >}}

site/content/3.11/concepts/data-structure/documents/schema-validation.md

Lines changed: 118 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,32 @@ description: >-
66
How to enforce attributes and their data types for documents of individual
77
collections using JSON Schema
88
---
9-
While ArangoDB is schema-less, it allows to enforce certain document structures
10-
on the collection level. The desired structure can be described in the popular
9+
While ArangoDB is schema-less, it allows you to enforce certain document structures
10+
on the collection level. You can describe the desired structure in the popular
1111
[JSON Schema](https://json-schema.org/) format (draft-4, without support for
1212
remote schemas for security reasons). The level of validation and a custom error
13-
message can be configured. The system attributes `_key`, `_id`, `_rev`, `_from`
13+
message are configurable. The system attributes `_key`, `_id`, `_rev`, `_from`
1414
and `_to` are ignored by the schema validation.
1515

16-
## Enable schema validation for a collection
16+
## Schema validation interfaces
1717

18-
Schema validation can be managed via the JavaScript API, typically
19-
using _arangosh_, as well as via the HTTP interface.
18+
The following sections show examples of how you can configure the
19+
schema validation for collections using the APIs of ArangoDB and
20+
the official drivers, as well as the ArangoDB Shell and the built-in web interface.
2021

21-
To enable schema validation either pass the `schema` property on collection
22-
creation or when updating the properties of an existing collection. It expects an
23-
object with the following attributes: `rule`, `level` and `message`.
22+
### Enable schema validation for a collection
2423

25-
- The `rule` attribute must contain the JSON Schema description.
26-
- `level` controls when the validation is applied.
27-
- `message` sets the message that is used when validation fails.
24+
You can define a schema when creating a collection as well as update the
25+
properties of a collection later on to add, modify, or remove a schema.
26+
27+
The `schema` property of a collection expects an object with the following
28+
attributes:
29+
30+
- `rule`: Must contain the JSON Schema description.
31+
- `level`: Controls when the validation is applied.
32+
- `message`: Defines the message that is used when validation fails.
33+
34+
See [Schema validation properties](#schema-validation-properties) for details.
2835

2936
{{< tabs "interfaces" >}}
3037

@@ -90,18 +97,6 @@ var coll = db._create("schemaCollection", { "schema": schema });
9097
db.schemaCollection.properties({ "schema": schema });
9198
~addIgnoreCollection(coll.name());
9299
```
93-
{{< comment >}}TODO: Move disabling/removing schema to separate headline?{{< /comment >}}
94-
95-
To remove an existing schema from a collection, a schema value of either `null`
96-
or `{}` (empty object) can be stored:
97-
98-
```js
99-
~var coll = db._collection("schemaCollection");
100-
/* Remove the schema of an existing collection */
101-
db.schemaCollection.properties({ "schema": null });
102-
~removeIgnoreCollection(coll.name());
103-
~db._drop(coll.name());
104-
```
105100

106101
See [`collection.properties()`](../../../develop/javascript-api/@arangodb/collection-object.md#collectionpropertiesproperties)
107102
in the _JavaScript API_ for details.
@@ -112,8 +107,8 @@ in the _JavaScript API_ for details.
112107
curl -XPUT -d '{"schema":{"rule":{"type":"object","properties":{"nums":{"type":"array","items":{"type":"number","maximum":6}}},"additionalProperties":{"type":"string"},"required":["nums"]},"level":"moderate","message":"The document does not contain an array of numbers in attribute \"nums\", one of the numbers is greater than 6, or another top-level attribute is not a string."}}' http://localhost:8529/_db/mydb/_api/collection/coll/properties
113108
```
114109

115-
See the [`GET /_db/{database-name}/_api/collection/{collection-name}/properties`](../../../develop/http-api/collections.md#get-the-properties-of-a-collection)
116-
endpoint in the _HTTP API_for details.
110+
See the [`PUT /_db/{database-name}/_api/collection/{collection-name}/properties`](../../../develop/http-api/collections.md#change-the-properties-of-a-collection)
111+
endpoint in the _HTTP API_ for details.
117112
{{< /tab >}}
118113

119114
{{< tab "JavaScript" >}}
@@ -216,7 +211,6 @@ in the _arangodb-java-driver_ documentation for details.
216211
```py
217212
coll = db.collection("coll")
218213
props = coll.configure(
219-
sync=True,
220214
schema={
221215
"rule": {
222216
"type": "object",
@@ -244,7 +238,101 @@ in the _python-arango_ documentation for details.
244238

245239
{{< /tabs >}}
246240

247-
## JSON Schema Rule
241+
### Remove schema validation for a collection
242+
243+
To remove an existing schema from a collection, set a `schema` value of either
244+
`null` or `{}` (empty object).
245+
246+
{{< tabs "interfaces" >}}
247+
248+
{{< tab "Web interface" >}}
249+
1. If necessary, [switch to the database](../databases.md#set-the-database-context)
250+
that contains the desired collection.
251+
2. Click **COLLECTIONS** in the main navigation.
252+
3. Click the card of the desired collection.
253+
4. Go to the **Schema** tab.
254+
5. You can temporarily disable the document validation by setting the validation
255+
`level` to `"none"`. To fully remove the schema from the collection, replace
256+
the entire configuration with `null`.
257+
6. Click the **Save** button.
258+
{{< /tab >}}
259+
260+
{{< tab "arangosh" >}}
261+
```js
262+
---
263+
name: arangosh_remove_collection_properties_schema
264+
description: ''
265+
---
266+
~var coll = db._collection("schemaCollection");
267+
db.schemaCollection.properties({ "schema": null });
268+
~removeIgnoreCollection(coll.name());
269+
~db._drop(coll.name());
270+
```
271+
272+
See [`collection.properties()`](../../../develop/javascript-api/@arangodb/collection-object.md#collectionpropertiesproperties)
273+
in the _JavaScript API_ for details.
274+
{{< /tab >}}
275+
276+
{{< tab "cURL" >}}
277+
```sh
278+
curl -XPUT -d '{"schema":null}' http://localhost:8529/_db/mydb/_api/collection/coll/properties
279+
```
280+
281+
See the [`PUT /_db/{database-name}/_api/collection/{collection-name}/properties`](../../../develop/http-api/collections.md#change-the-properties-of-a-collection)
282+
endpoint in the _HTTP API_ for details.
283+
{{< /tab >}}
284+
285+
{{< tab "JavaScript" >}}
286+
```js
287+
let coll = db.collection("coll");
288+
const props = await coll.properties({ schema: null });
289+
```
290+
291+
See [`DocumentCollection.properties()`](https://arangodb.github.io/arangojs/latest/interfaces/collections.DocumentCollection.html#properties.properties-2)
292+
in the _arangojs_ documentation for details.
293+
{{< /tab >}}
294+
295+
{{< tab "Go" >}}
296+
```go
297+
ctx := context.Background()
298+
coll, err := db.GetCollection(ctx, "coll", nil)
299+
err = coll.SetProperties(ctx, arangodb.SetCollectionPropertiesOptions{
300+
Schema: &arangodb.CollectionSchemaOptions{} // empty object
301+
})
302+
```
303+
304+
See [`Collection.SetProperties()`](https://pkg.go.dev/github.com/arangodb/go-driver/v2/arangodb#Collection)
305+
in the _go-driver_ v2 documentation for details.
306+
{{< /tab >}}
307+
308+
{{< tab "Java" >}}
309+
```java
310+
CollectionPropertiesOptions options = new CollectionPropertiesOptions()
311+
.schema(null);
312+
313+
ArangoCollection coll = db.collection("coll");
314+
CollectionPropertiesEntity props = coll.changeProperties(options);
315+
```
316+
317+
See [`ArangoCollection.changeProperties()`](https://www.javadoc.io/doc/com.arangodb/arangodb-java-driver/latest/com/arangodb/ArangoCollection.html#changeProperties%28com.arangodb.model.CollectionPropertiesOptions%29)
318+
in the _arangodb-java-driver_ documentation for details.
319+
{{< /tab >}}
320+
321+
{{< tab "Python" >}}
322+
```py
323+
coll = db.collection("coll")
324+
props = coll.configure(schema={})
325+
```
326+
327+
See [`Collection.configure()`](https://docs.python-arango.com/en/main/specs.html#arango.collection.Collection.configure)
328+
in the _python-arango_ documentation for details.
329+
{{< /tab >}}
330+
331+
{{< /tabs >}}
332+
333+
## Schema validation properties
334+
335+
### JSON Schema Rule
248336

249337
The `rule` must be a valid JSON Schema object as outlined in the
250338
[specification](https://json-schema.org/specification.html).
@@ -265,7 +353,7 @@ attribute to integer values, use `"type": "number"` together with `"multipleOf":
265353
Remote schemas are not supported for security reasons.
266354
{{< /security >}}
267355

268-
## Levels
356+
### Levels
269357

270358
The level controls when the validation is triggered:
271359

@@ -279,7 +367,7 @@ The level controls when the validation is triggered:
279367
- `strict`: All new and modified document must strictly pass validation.
280368
No exceptions are made (default).
281369

282-
## Error message
370+
### Error message
283371

284372
If the schema validation for a document fails, then a generic error is raised.
285373
You may customize the error message via the `message` attribute to provide a

site/content/3.12/about-arangodb/use-cases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ aliases:
1212
---
1313
## ArangoDB as a Graph Database
1414

15-
ArangoDB as a **graph database** is a great fit for use cases like fraud detection,
15+
ArangoDB as a graph database is a great fit for use cases like fraud detection,
1616
knowledge graphs, recommendation engines, identity and access management,
1717
network and IT operations, social media management, traffic management, and many
1818
more.

site/content/3.12/concepts/data-structure/collections.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ in the _JavaScript API_ for details.
216216
curl -d '{"name":"coll"}' http://localhost:8529/_db/mydb/_api/collection
217217
```
218218

219-
See the [`POST /_db/{database-name}/_api/collection`](../../develop/http-api/databases.md#create-a-database)
219+
See the [`POST /_db/{database-name}/_api/collection`](../../develop/http-api/collections.md#create-a-collection)
220220
endpoint in the _HTTP API_ for details.
221221
{{< /tab >}}
222222

@@ -397,7 +397,7 @@ in the _JavaScript API_ for details.
397397
curl http://localhost:8529/_db/mydb/_api/collection
398398
```
399399

400-
See the [`GET /_db/{database-name}/_api/collection`](../../develop/http-api/collections.md#get-the-collection-information)
400+
See the [`GET /_db/{database-name}/_api/collection`](../../develop/http-api/collections.md#list-all-collections)
401401
endpoint in the _HTTP API_ for details.
402402
{{< /tab >}}
403403

site/content/3.12/concepts/data-structure/documents/computed-values.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ curl -XPUT -d '{"computedValues":[{"name":"title","expression":"RETURN \"TBA\"",
146146
```
147147

148148
See the [`PUT /_db/{database-name}/_api/collection/{collection-name}/properties`](../../../develop/http-api/collections.md#change-the-properties-of-a-collection)
149-
endpoint in the _HTTP API_for details.
149+
endpoint in the _HTTP API_ for details.
150150
{{< /tab >}}
151151

152152
{{< tab "JavaScript" >}}

0 commit comments

Comments
 (0)