From cd9df3460e875dd9ae99ac9dafb2d1e6b7e5ecec Mon Sep 17 00:00:00 2001 From: Aurelijus Banelis Date: Sat, 15 Aug 2015 22:22:27 +0300 Subject: [PATCH 1/5] Documentation: Example of user data in _createDatabase --- arangod/V8Server/v8-vocbase.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arangod/V8Server/v8-vocbase.cpp b/arangod/V8Server/v8-vocbase.cpp index ea4801627b..3101fe60eb 100644 --- a/arangod/V8Server/v8-vocbase.cpp +++ b/arangod/V8Server/v8-vocbase.cpp @@ -3357,8 +3357,13 @@ static void CreateDatabaseCoordinator (const v8::FunctionCallbackInfo /// require("org/arangodb/users").update(username, password, true); /// require("org/arangodb/users").remove(username); /// ``` +/// Alternatively, you can specify user data directly. For example: /// -/// This method can only be used from within the *_system* database. +/// ```js +/// db._createDatabase("newDB", [], [{ username: "newUser", passwd: "123456", active: true}]) +/// ``` +/// +/// Those methods can only be used from within the *_system* database. /// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// From 078db04650d67905450549678aac1c8e2ce2e8db Mon Sep 17 00:00:00 2001 From: Aurelijus Banelis Date: Sat, 15 Aug 2015 22:28:51 +0300 Subject: [PATCH 2/5] Git ignore for CMAKE generated files --- .gitignore | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.gitignore b/.gitignore index b3007ed5cf..0d5b59e6c1 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,22 @@ core TAGS tags +CMakeCache.txt +CMakeFiles/ +CPackConfig.cmake +CPackSourceConfig.cmake +CTestTestfile.cmake +UnitTests/CMakeFiles/ +UnitTests/CTestTestfile.cmake +UnitTests/cmake_install.cmake +arangod/CMakeFiles/ +arangod/cmake_install.cmake +arangosh/CMakeFiles/ +arangosh/cmake_install.cmake +cmake_install.cmake +lib/CMakeFiles/ +lib/cmake_install.cmake + Documentation/Examples/*.generated Documentation/Books/Users/book.json Documentation/Books/Users/manual.epub From 9c075561f45011c842aace24de62926801e35553 Mon Sep 17 00:00:00 2001 From: Aurelijus Banelis Date: Sun, 16 Aug 2015 17:25:27 +0300 Subject: [PATCH 3/5] Documentation: collection.updateByExample can append not only change From example it was not clear, that old fields are left unchanged. So it is not confused with replace whole document: replaceByExample --- ...cumentsCollectionUpdateByExample.generated | 19 +++++++++++++++---- .../org/arangodb/arango-collection-common.js | 6 +++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Documentation/Examples/012_documentsCollectionUpdateByExample.generated b/Documentation/Examples/012_documentsCollectionUpdateByExample.generated index dcf31f1d79..f3431b6222 100644 --- a/Documentation/Examples/012_documentsCollectionUpdateByExample.generated +++ b/Documentation/Examples/012_documentsCollectionUpdateByExample.generated @@ -1,8 +1,19 @@ -arangosh> db.example.save({ Hello : "world" }); +arangosh> db.example.save({ Hello : "world", foo : "bar" }); { - "_id" : "example/450753419", - "_rev" : "450753419", - "_key" : "450753419" + "_id" : "example/450817260", + "_rev" : "450817260", + "_key" : "450817260" } arangosh> db.example.updateByExample({ Hello: "world" }, { Hello: "foo", World: "bar" }, false); 1 +arangosh> db.example.byExample({ Hello: "foo" }).toArray() +[ + { + "_id" : "example/450817260", + "_key" : "450817260", + "_rev" : "451144940", + "Hello" : "foo", + "foo" : "bar", + "World" : "bar" + } +] diff --git a/js/common/modules/org/arangodb/arango-collection-common.js b/js/common/modules/org/arangodb/arango-collection-common.js index a1c6c38023..3c048c46f3 100644 --- a/js/common/modules/org/arangodb/arango-collection-common.js +++ b/js/common/modules/org/arangodb/arango-collection-common.js @@ -989,6 +989,9 @@ ArangoCollection.prototype.replaceByExample = function (example, newValue, waitF /// The document meta-attributes such as *_id*, *_key*, *_from*, /// *_to* cannot be updated. /// +/// Partial update could also be used to append new fields, +/// if there were no old field with same name. +/// /// `collection.updateByExample(document, newValue, keepNull, waitForSync)` /// /// The optional *keepNull* parameter can be used to modify the behavior when @@ -1019,8 +1022,9 @@ ArangoCollection.prototype.replaceByExample = function (example, newValue, waitF /// /// @EXAMPLE_ARANGOSH_OUTPUT{012_documentsCollectionUpdateByExample} /// ~ db._create("example"); -/// db.example.save({ Hello : "world" }); +/// db.example.save({ Hello : "world", foo : "bar" }); /// db.example.updateByExample({ Hello: "world" }, { Hello: "foo", World: "bar" }, false); +/// db.example.byExample({ Hello: "foo" }).toArray() /// ~ db._drop("example"); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// @endDocuBlock From 9c7c1ad88b7ca9e8d7c7c0439780a94f423bc0d4 Mon Sep 17 00:00:00 2001 From: Aurelijus Banelis Date: Sun, 16 Aug 2015 18:56:45 +0300 Subject: [PATCH 4/5] Documentation: include createEdgeCollection in example As it is useful for newcomer to know, how to create "vertex" and "relation". It is first example, so all inforamtion should be included to try example. --- arangod/V8Server/v8-collection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arangod/V8Server/v8-collection.cpp b/arangod/V8Server/v8-collection.cpp index 1f9ae04403..c73a982400 100644 --- a/arangod/V8Server/v8-collection.cpp +++ b/arangod/V8Server/v8-collection.cpp @@ -2963,8 +2963,8 @@ static string GetId (const v8::FunctionCallbackInfo& args, int which) /// @EXAMPLES /// /// @EXAMPLE_ARANGOSH_OUTPUT{EDGCOL_01_SaveEdgeCol} -/// ~ db._create("vertex"); -/// ~ db._createEdgeCollection("relation"); +/// db._create("vertex"); +/// db._createEdgeCollection("relation"); /// v1 = db.vertex.insert({ name : "vertex 1" }); /// v2 = db.vertex.insert({ name : "vertex 2" }); /// e1 = db.relation.insert(v1, v2, { label : "knows" }); From 3dce622c8212e4b8b1d09f909760d68a3fd833b0 Mon Sep 17 00:00:00 2001 From: Aurelijus Banelis Date: Sun, 16 Aug 2015 18:59:55 +0300 Subject: [PATCH 5/5] Documentation: How to update edge From context it was confusing about changing type/edge/field of collection/document/edge. It is very important to know, how to change edge, as it is second most used operation in graph database (first is graph traversal). --- Documentation/Books/Users/Edges/README.mdpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/Books/Users/Edges/README.mdpp b/Documentation/Books/Users/Edges/README.mdpp index 0af6e87174..9321d3ae16 100644 --- a/Documentation/Books/Users/Edges/README.mdpp +++ b/Documentation/Books/Users/Edges/README.mdpp @@ -13,6 +13,9 @@ The values of *_from* and *_to* are immutable once saved. are connection documents that reference other documents. The type of a collection must be specified when a collection is created and cannot be changed afterwards. +To change edge endpoints you would need to remove old document/edge and insert new one. +Other fields can be updated as in default collection. + !SECTION Working with Edges !SUBSECTION Insert