-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC-440 | Add interface examples for APIs and GUI (Concepts section) #648
base: main
Are you sure you want to change the base?
Conversation
Deploy Preview Available Via |
/generate |
/generate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've only checked the arangojs examples but they LGTM
|
||
{{< tab "Java" >}} | ||
```java | ||
ArangoCollection coll = db.collection("coll"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ArangoCollection coll = db.collection("coll"); | |
CollectionEntity coll = db.collection("coll").getInfo(); |
ArangoCollection coll = db.collection("coll"); | ||
``` | ||
|
||
See [`ArangoDB.collection()`](https://www.javadoc.io/doc/com.arangodb/arangodb-java-driver/latest/com/arangodb/ArangoDB.html#db%28java.lang.String%29) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See [`ArangoDB.collection()`](https://www.javadoc.io/doc/com.arangodb/arangodb-java-driver/latest/com/arangodb/ArangoDB.html#db%28java.lang.String%29) | |
See [`ArangoCollection.getInfo()`](https://www.javadoc.io/static/com.arangodb/arangodb-java-driver/latest/com/arangodb/ArangoCollection.html#getInfo()) |
{{< tab "Java" >}} | ||
```java | ||
CollectionPropertiesOptions options = new CollectionPropertiesOptions() | ||
.waitForSync(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.waitForSync(true); | |
.waitForSync(true) | |
.replicationFactor(ReplicationFactor.of(3)); |
ArangoCollection coll = db.collection("coll"); | ||
CollectionPropertiesEntity props = coll.changeProperties(options); | ||
``` | ||
{{< comment >}}TODO: setReplicationFactor not yet supported by Java driver{{< /comment >}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{{< comment >}}TODO: setReplicationFactor not yet supported by Java driver{{< /comment >}} |
CollectionEntity coll = db.collection("coll"); | ||
|
||
// Single document | ||
coll.insertDocument(new BaseDocument("the-document-key") | ||
.addAttribute("name", "ArangoDB") | ||
.addAttribute("tags", [ "graph", "database", "NoSQL" ]) | ||
.addAttribute("scalable", true) | ||
.addAttribute("company", new Map<String, Object>() | ||
.put("name", "ArangoDB Inc.") | ||
.put("founded", 2015) | ||
) | ||
.addAttribute("name", "ArangoDB") | ||
); | ||
|
||
// Multiple documents | ||
coll.insertDocuments([ | ||
new BaseDocument("one"), | ||
new BaseDocument("two"), | ||
new BaseDocument("three") | ||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CollectionEntity coll = db.collection("coll"); | |
// Single document | |
coll.insertDocument(new BaseDocument("the-document-key") | |
.addAttribute("name", "ArangoDB") | |
.addAttribute("tags", [ "graph", "database", "NoSQL" ]) | |
.addAttribute("scalable", true) | |
.addAttribute("company", new Map<String, Object>() | |
.put("name", "ArangoDB Inc.") | |
.put("founded", 2015) | |
) | |
.addAttribute("name", "ArangoDB") | |
); | |
// Multiple documents | |
coll.insertDocuments([ | |
new BaseDocument("one"), | |
new BaseDocument("two"), | |
new BaseDocument("three") | |
]); | |
ArangoCollection coll = db.collection("coll"); | |
// Single document | |
BaseDocument doc = new BaseDocument("the-document-key"); | |
doc.addAttribute("name", "ArangoDB"); | |
doc.addAttribute("tags", List.of("graph", "database", "NoSQL")); | |
doc.addAttribute("scalable", true); | |
doc.addAttribute("company", Map.of( | |
"name", "ArangoDB Inc.", | |
"founded", 2015 | |
)); | |
doc.addAttribute("name", "ArangoDB"); | |
coll.insertDocument(doc); | |
// Multiple documents | |
coll.insertDocuments(List.of( | |
new BaseDocument("one"), | |
new BaseDocument("two"), | |
new BaseDocument("three") | |
)); |
// Single document | ||
DocumentDeleteEntity<Void> result = coll.deleteDocument("the-document-key"); | ||
|
||
// Multiple documents | ||
for (MultiDocumentEntity<DocumentDeleteEntity<Void>> result : coll.deleteDocuments(["one", "two", "three"])) { | ||
// ... | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Single document | |
DocumentDeleteEntity<Void> result = coll.deleteDocument("the-document-key"); | |
// Multiple documents | |
for (MultiDocumentEntity<DocumentDeleteEntity<Void>> result : coll.deleteDocuments(["one", "two", "three"])) { | |
// ... | |
} | |
// Single document | |
DocumentDeleteEntity<Void> result = coll.deleteDocument("the-document-key"); | |
// Multiple documents | |
MultiDocumentEntity<DocumentDeleteEntity<Void>> multipleResult = | |
coll.deleteDocuments(List.of("one", "two", "three")); |
String schemaRule = ( | ||
"{" + | ||
" \"type\": \"object\"," + | ||
" \"properties\": {" + | ||
" \"nums\": {" + | ||
" \"type\": \"array\"," + | ||
" \"items\": {" + | ||
" \"type\": \"number\"," + | ||
" \"minimum\": 6" + | ||
" }" + | ||
" }" + | ||
" }," + | ||
" \"additionalProperties\": { \"type\": \"string\" }," + | ||
" \"required\": [\"nums\"]" + | ||
"}"); | ||
|
||
CollectionPropertiesOptions props = new CollectionPropertiesOptions() | ||
.schema(new CollectionSchema() | ||
.setRule(schemaRule) | ||
.setLevel(CollectionSchema.Level.MODERATE) | ||
.setMessage("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.") | ||
); | ||
|
||
ArangoCollection coll = db.collection("coll"); | ||
CollectionPropertiesEntity = coll.changeProperties(props); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String schemaRule = ( | |
"{" + | |
" \"type\": \"object\"," + | |
" \"properties\": {" + | |
" \"nums\": {" + | |
" \"type\": \"array\"," + | |
" \"items\": {" + | |
" \"type\": \"number\"," + | |
" \"minimum\": 6" + | |
" }" + | |
" }" + | |
" }," + | |
" \"additionalProperties\": { \"type\": \"string\" }," + | |
" \"required\": [\"nums\"]" + | |
"}"); | |
CollectionPropertiesOptions props = new CollectionPropertiesOptions() | |
.schema(new CollectionSchema() | |
.setRule(schemaRule) | |
.setLevel(CollectionSchema.Level.MODERATE) | |
.setMessage("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.") | |
); | |
ArangoCollection coll = db.collection("coll"); | |
CollectionPropertiesEntity = coll.changeProperties(props); | |
String schemaRule = ( | |
"{" + | |
" \"type\": \"object\"," + | |
" \"properties\": {" + | |
" \"nums\": {" + | |
" \"type\": \"array\"," + | |
" \"items\": {" + | |
" \"type\": \"number\"," + | |
" \"minimum\": 6" + | |
" }" + | |
" }" + | |
" }," + | |
" \"additionalProperties\": { \"type\": \"string\" }," + | |
" \"required\": [\"nums\"]" + | |
"}"); | |
CollectionPropertiesOptions props = new CollectionPropertiesOptions() | |
.schema(new CollectionSchema() | |
.setRule(schemaRule) | |
.setLevel(CollectionSchema.Level.MODERATE) | |
.setMessage("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.") | |
); | |
ArangoCollection coll = db.collection("coll"); | |
CollectionPropertiesEntity changedProperties = coll.changeProperties(props); |
ArangoView view = db.view("myView"); | ||
|
||
ArangoSearch viewSearch = db.arangoSearch("myArangoSearchView"); | ||
SearchAlias viewAlias = db.searchAlias("mySearchAliasView"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ArangoView view = db.view("myView"); | |
ArangoSearch viewSearch = db.arangoSearch("myArangoSearchView"); | |
SearchAlias viewAlias = db.searchAlias("mySearchAliasView"); | |
ViewEntity view = db.view("myView").getInfo(); | |
ViewEntity viewSearch = db.arangoSearch("myArangoSearchView").getInfo(); | |
ViewEntity viewAlias = db.searchAlias("mySearchAliasView").getInfo(); |
ArangoSearch viewSearch = db.view("myArangoSearchView"); | ||
ArangoSearchPropertiesEntity viewSearch.getProperties(); | ||
|
||
SearchAlias viewAlias = db.view("mySearchAliasView"); | ||
SearchAliasPropertiesEntity viewAlias.getProperties(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ArangoSearch viewSearch = db.view("myArangoSearchView"); | |
ArangoSearchPropertiesEntity viewSearch.getProperties(); | |
SearchAlias viewAlias = db.view("mySearchAliasView"); | |
SearchAliasPropertiesEntity viewAlias.getProperties(); | |
ArangoSearch viewSearch = db.arangoSearch("myArangoSearchView"); | |
ArangoSearchPropertiesEntity viewSearchProperties = viewSearch.getProperties(); | |
SearchAlias viewAlias = db.searchAlias("mySearchAliasView"); | |
SearchAliasPropertiesEntity viewAliasProperties = viewAlias.getProperties(); |
ArangoSearchPropertiesOptions options = new ArangoSearchPropertiesOptions(); | ||
options.cleanupIntervalStep(12L); | ||
options.link(CollectionLink.on("coll") | ||
.includeAllFields(true) | ||
); | ||
|
||
ArangoSearch viewSearch = db.view("myArangoSearchView"); | ||
ArangoSearchPropertiesEntity viewSearch.updateProperties(options); | ||
|
||
SearchAlias viewAlias = db.view("mySearchAliasView"); | ||
SearchAliasPropertiesEntity viewAlias.updateProperties( | ||
new SearchAliasPropertiesOptions() | ||
.indexes(new SearchAliasIndex("coll", "idx")) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ArangoSearchPropertiesOptions options = new ArangoSearchPropertiesOptions(); | |
options.cleanupIntervalStep(12L); | |
options.link(CollectionLink.on("coll") | |
.includeAllFields(true) | |
); | |
ArangoSearch viewSearch = db.view("myArangoSearchView"); | |
ArangoSearchPropertiesEntity viewSearch.updateProperties(options); | |
SearchAlias viewAlias = db.view("mySearchAliasView"); | |
SearchAliasPropertiesEntity viewAlias.updateProperties( | |
new SearchAliasPropertiesOptions() | |
.indexes(new SearchAliasIndex("coll", "idx")) | |
); | |
ArangoSearch viewSearch = db.arangoSearch("myArangoSearchView"); | |
ArangoSearchPropertiesEntity viewSearchProperties = viewSearch.updateProperties( | |
new ArangoSearchPropertiesOptions() | |
.cleanupIntervalStep(12L) | |
.link(CollectionLink.on("coll") | |
.includeAllFields(true) | |
) | |
); | |
SearchAlias viewAlias = db.searchAlias("mySearchAliasView"); | |
SearchAliasPropertiesEntity viewAliasProperties = viewAlias.updateProperties( | |
new SearchAliasPropertiesOptions() | |
.indexes(new SearchAliasIndex("coll", "idx")) | |
); |
… for endpoints that require this context
.name("title") | ||
.expression("RETURN \"TBA\"") | ||
.overwrite(false) | ||
.computeOn(ComputeOn.insert, ComputeOn.update, ComputeOn.replace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rashtao I added the examples for Computed Values now too.
Is it necessary to use ComputedValue.ComputeOn.*
here to refer to the elements of the enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.computeOn(ComputeOn.insert, ComputeOn.update, ComputeOn.replace) | |
.computeOn(ComputedValue.ComputeOn.insert, ComputedValue.ComputeOn.update, ComputedValue.ComputeOn.replace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python examples look good,2 small adjustments:
```py | ||
coll = db.collection("coll") | ||
props = coll.configure( | ||
computed_values: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
computed_values: [ | |
computed_values=[ |
|
||
{{< tab "Python" >}} | ||
```py | ||
coll = db.get_collection("coll") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coll = db.get_collection("coll") | |
coll = db.collection("coll") |
Description
Add examples for all official drivers, cURL, and the web interface to the pages under Concepts > Data structure for common operations that were previously only described for arangosh.
The driver code examples must be reviewed and possibly adjusted to include some error handling.
Up for discussion: How much should the examples show? For example, should setting options like
returnNew
be covered or should the examples rather be kept as minimal as possible?Preview: https://deploy-preview-648--docs-hugo.netlify.app/stable/concepts/data-structure/databases/#set-the-database-context ff.
Upstream PRs