From 4fe43c5b4908799e7359811dffc38e71b46dfbae Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Mon, 8 Sep 2014 10:59:07 +0200 Subject: [PATCH] added derived files --- .../aardvark/frontend/js/bootstrap/errors.js | 2 + .../frontend/js/bootstrap/module-console.js | 6 +- .../frontend/js/bootstrap/monkeypatches.js | 2 + .../js/client/bootstrap/module-internal.js | 5 +- .../aardvark/frontend/js/client/client.js | 14 +++- .../js/modules/org/arangodb/aql/functions.js | 1 + .../org/arangodb/arango-collection-common.js | 1 + .../modules/org/arangodb/arango-collection.js | 3 +- .../modules/org/arangodb/arango-database.js | 1 + .../org/arangodb/arango-query-cursor.js | 1 + .../org/arangodb/arango-statement-common.js | 5 +- .../modules/org/arangodb/arango-statement.js | 1 + .../js/modules/org/arangodb/arangosh.js | 1 + .../js/modules/org/arangodb/general-graph.js | 5 +- .../modules/org/arangodb/graph-blueprint.js | 1 + .../js/modules/org/arangodb/graph-common.js | 1 + .../frontend/js/modules/org/arangodb/graph.js | 1 + .../modules/org/arangodb/graph/traversal.js | 1 + .../frontend/js/modules/org/arangodb/is.js | 5 +- .../org/arangodb/simple-query-common.js | 1 + .../js/modules/org/arangodb/simple-query.js | 1 + .../js/modules/org/arangodb/tutorial.js | 81 +++++++++---------- 22 files changed, 82 insertions(+), 58 deletions(-) diff --git a/js/apps/system/aardvark/frontend/js/bootstrap/errors.js b/js/apps/system/aardvark/frontend/js/bootstrap/errors.js index b083800874..27fbc1d985 100644 --- a/js/apps/system/aardvark/frontend/js/bootstrap/errors.js +++ b/js/apps/system/aardvark/frontend/js/bootstrap/errors.js @@ -1,3 +1,4 @@ +/*jshint maxlen: 200 */ /*global require */ //////////////////////////////////////////////////////////////////////////////// @@ -5,6 +6,7 @@ //////////////////////////////////////////////////////////////////////////////// (function () { + "use strict"; var internal = require("internal"); internal.errors = { diff --git a/js/apps/system/aardvark/frontend/js/bootstrap/module-console.js b/js/apps/system/aardvark/frontend/js/bootstrap/module-console.js index d04d21f465..b500e49e9d 100644 --- a/js/apps/system/aardvark/frontend/js/bootstrap/module-console.js +++ b/js/apps/system/aardvark/frontend/js/bootstrap/module-console.js @@ -1,3 +1,4 @@ +/*jshint -W051: true */ /*global require, SYS_GETLINE, SYS_LOG, jqconsole */ //////////////////////////////////////////////////////////////////////////////// @@ -28,8 +29,7 @@ //////////////////////////////////////////////////////////////////////////////// (function () { - // cannot use strict here as we are going to delete globals - + /*jshint strict: false */ var exports = require("console"); var sprintf = require("internal").sprintf; @@ -112,7 +112,7 @@ else if (arg === null) { arg = "null"; } - else if (arg.__proto__ === Object.prototype || Array.isArray(arg)) { + else if (Object.prototype.isPrototypeOf(arg) || Array.isArray(arg)) { arg = inspect(arg, {prettyPrint: false}); } } diff --git a/js/apps/system/aardvark/frontend/js/bootstrap/monkeypatches.js b/js/apps/system/aardvark/frontend/js/bootstrap/monkeypatches.js index 05800a391e..824e0087e4 100644 --- a/js/apps/system/aardvark/frontend/js/bootstrap/monkeypatches.js +++ b/js/apps/system/aardvark/frontend/js/bootstrap/monkeypatches.js @@ -1,3 +1,5 @@ +/*jshint strict: false */ + //////////////////////////////////////////////////////////////////////////////// /// @brief monkey-patches to built-in prototypes /// diff --git a/js/apps/system/aardvark/frontend/js/client/bootstrap/module-internal.js b/js/apps/system/aardvark/frontend/js/client/bootstrap/module-internal.js index cbe29bb07c..0af55bd40c 100644 --- a/js/apps/system/aardvark/frontend/js/client/bootstrap/module-internal.js +++ b/js/apps/system/aardvark/frontend/js/client/bootstrap/module-internal.js @@ -1,4 +1,5 @@ -/*global require, ArangoConnection, print, SYS_ARANGO, window */ +/*jshint strict: false, -W051: true */ +/*global require, ArangoConnection, SYS_ARANGO, window */ //////////////////////////////////////////////////////////////////////////////// /// @brief module "internal" @@ -309,7 +310,7 @@ var i = 0; - return format.replace(/%[dfs]/, function (match) { + return format.replace(/%[dfs]/, function () { return String(arguments[++i]); }); }; diff --git a/js/apps/system/aardvark/frontend/js/client/client.js b/js/apps/system/aardvark/frontend/js/client/client.js index a9169cdbc6..f4b1019371 100644 --- a/js/apps/system/aardvark/frontend/js/client/client.js +++ b/js/apps/system/aardvark/frontend/js/client/client.js @@ -1,4 +1,5 @@ -/*global require, console, IS_EXECUTE_SCRIPT, IS_EXECUTE_STRING, IS_CHECK_SCRIPT, IS_UNIT_TESTS, IS_JS_LINT */ +/*jshint unused: false, -W051: true */ +/*global require, console: true, IS_EXECUTE_SCRIPT, IS_EXECUTE_STRING, IS_CHECK_SCRIPT, IS_UNIT_TESTS, IS_JS_LINT */ //////////////////////////////////////////////////////////////////////////////// /// @brief ArangoShell client API @@ -36,6 +37,7 @@ //////////////////////////////////////////////////////////////////////////////// function start_pager () { + "use strict"; var internal = require("internal"); internal.startPager(); } @@ -45,6 +47,7 @@ function start_pager () { //////////////////////////////////////////////////////////////////////////////// function stop_pager () { + "use strict"; var internal = require("internal"); internal.stopPager(); } @@ -54,6 +57,7 @@ function stop_pager () { //////////////////////////////////////////////////////////////////////////////// function help () { + "use strict"; var internal = require("internal"); var arangodb = require("org/arangodb"); var arangosh = require("org/arangodb/arangosh"); @@ -71,6 +75,7 @@ function help () { //////////////////////////////////////////////////////////////////////////////// function clear () { + "use strict"; var internal = require("internal"); var i; var result = ''; @@ -85,8 +90,8 @@ function clear () { /// @brief global 'console' //////////////////////////////////////////////////////////////////////////////// -if (console === undefined) { - var console = require("console"); +if (typeof console === 'undefined') { + console = require("console"); } //////////////////////////////////////////////////////////////////////////////// @@ -134,6 +139,7 @@ var tutorial = require("org/arangodb/tutorial"); //////////////////////////////////////////////////////////////////////////////// (function() { + "use strict"; var internal = require("internal"); var arangosh = require("org/arangodb/arangosh"); var special; @@ -168,6 +174,7 @@ var tutorial = require("org/arangodb/tutorial"); //////////////////////////////////////////////////////////////////////////////// (function () { + /*jshint strict: false */ var __special__; try { @@ -185,6 +192,7 @@ var tutorial = require("org/arangodb/tutorial"); var __rcf__ = __fs__.join(__fs__.home(), ".arangosh.rc"); if (__fs__.exists(__rcf__)) { + /*jshint evil: true */ var __content__ = __fs__.read(__rcf__); eval(__content__); } diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/aql/functions.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/aql/functions.js index aa059686ce..9a1ff507f5 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/aql/functions.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/aql/functions.js @@ -1,4 +1,5 @@ module.define("org/arangodb/aql/functions", function(exports, module) { +/*jshint strict: false */ /*global require, exports */ //////////////////////////////////////////////////////////////////////////////// diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-collection-common.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-collection-common.js index 4e2c3c270d..0bfdf3b4ae 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-collection-common.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-collection-common.js @@ -1,4 +1,5 @@ module.define("org/arangodb/arango-collection-common", function(exports, module) { +/*jshint strict: false, unused: false */ /*global require */ //////////////////////////////////////////////////////////////////////////////// diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-collection.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-collection.js index 9eae00aa32..7b96d9e2a7 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-collection.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-collection.js @@ -1,4 +1,5 @@ module.define("org/arangodb/arango-collection", function(exports, module) { +/*jshint strict: false */ /*global require, exports */ //////////////////////////////////////////////////////////////////////////////// @@ -159,7 +160,7 @@ ArangoCollection.prototype._documenturl = function (id) { /// @brief return the base url for collection index usage //////////////////////////////////////////////////////////////////////////////// -ArangoCollection.prototype._indexurl = function (suffix) { +ArangoCollection.prototype._indexurl = function () { return this._prefixurl("/_api/index?collection=" + encodeURIComponent(this.name())); }; diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-database.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-database.js index 06d4e1859b..243e8c1b6b 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-database.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-database.js @@ -1,4 +1,5 @@ module.define("org/arangodb/arango-database", function(exports, module) { +/*jshint strict: false */ /*global require, exports */ //////////////////////////////////////////////////////////////////////////////// diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-query-cursor.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-query-cursor.js index b44b0633e3..f7d9b624f1 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-query-cursor.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-query-cursor.js @@ -1,4 +1,5 @@ module.define("org/arangodb/arango-query-cursor", function(exports, module) { +/*jshint strict: false */ /*global require, exports */ //////////////////////////////////////////////////////////////////////////////// diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-statement-common.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-statement-common.js index 4933f1c452..e018494325 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-statement-common.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-statement-common.js @@ -1,5 +1,6 @@ module.define("org/arangodb/arango-statement-common", function(exports, module) { -/*global require, exports */ +/*jshint strict: false */ +/*global exports */ //////////////////////////////////////////////////////////////////////////////// /// @brief Arango statements @@ -190,7 +191,7 @@ ArangoStatement.prototype.setOptions = function (value) { //////////////////////////////////////////////////////////////////////////////// ArangoStatement.prototype.setQuery = function (query) { - this._query = query; + this._query = (query && typeof query.toAQL === 'function') ? query.toAQL() : query; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-statement.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-statement.js index 783ca706da..3a75ec3b46 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-statement.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arango-statement.js @@ -1,4 +1,5 @@ module.define("org/arangodb/arango-statement", function(exports, module) { +/*jshint strict: false */ /*global require, exports */ //////////////////////////////////////////////////////////////////////////////// diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arangosh.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arangosh.js index 497d278a68..d5e9b0ab58 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arangosh.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/arangosh.js @@ -1,4 +1,5 @@ module.define("org/arangodb/arangosh", function(exports, module) { +/*jshint strict: false */ /*global require, exports */ //////////////////////////////////////////////////////////////////////////////// diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/general-graph.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/general-graph.js index c90ccf6dc7..234ebf5197 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/general-graph.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/general-graph.js @@ -1,5 +1,6 @@ module.define("org/arangodb/general-graph", function(exports, module) { -/*global require, exports, Graph, ArangoClusterComm, arguments */ +/*jshint strict: false */ +/*global require, exports, ArangoClusterComm */ //////////////////////////////////////////////////////////////////////////////// /// @brief Graph functionality @@ -1721,7 +1722,7 @@ var _create = function (graphName, edgeDefinitions, orphanCollections, options) ); try { - var g = gdb.document(graphName); + gdb.document(graphName); } catch (e) { if (e.errorNum !== errors.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code) { throw e; diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph-blueprint.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph-blueprint.js index 8cce3ec23f..eaae1fc84b 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph-blueprint.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph-blueprint.js @@ -1,4 +1,5 @@ module.define("org/arangodb/graph-blueprint", function(exports, module) { +/*jshint strict: false */ /*global require, exports */ //////////////////////////////////////////////////////////////////////////////// diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph-common.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph-common.js index 0eab6cc7eb..02ec18f56d 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph-common.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph-common.js @@ -1,4 +1,5 @@ module.define("org/arangodb/graph-common", function(exports, module) { +/*jshint strict: false */ /*global require, exports */ //////////////////////////////////////////////////////////////////////////////// diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph.js index 0b3aa8ef76..6e147874ed 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph.js @@ -1,4 +1,5 @@ module.define("org/arangodb/graph", function(exports, module) { +/*jshint strict: false */ /*global require, exports */ //////////////////////////////////////////////////////////////////////////////// diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph/traversal.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph/traversal.js index 62413c8540..fbf7f8eccd 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph/traversal.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/graph/traversal.js @@ -1,4 +1,5 @@ module.define("org/arangodb/graph/traversal", function(exports, module) { +/*jshint strict: false, unused: false */ /*global require, exports, ArangoClusterComm */ //////////////////////////////////////////////////////////////////////////////// diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/is.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/is.js index 2769288a97..2724a2de12 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/is.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/is.js @@ -1,5 +1,5 @@ module.define("org/arangodb/is", function(exports, module) { -/*global require, exports */ +/*global exports */ //////////////////////////////////////////////////////////////////////////////// /// @brief Check if something is something @@ -31,8 +31,7 @@ module.define("org/arangodb/is", function(exports, module) { // Check if a value is not undefined or null var existy = function (x) { "use strict"; - // This is != on purpose to also check for undefined - return x != null; + return x !== null && x !== undefined; }; // Check if a value is undefined or null diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/simple-query-common.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/simple-query-common.js index d6c788e607..741b24e7d1 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/simple-query-common.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/simple-query-common.js @@ -1,4 +1,5 @@ module.define("org/arangodb/simple-query-common", function(exports, module) { +/*jshint strict: false */ /*global require, exports */ //////////////////////////////////////////////////////////////////////////////// diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/simple-query.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/simple-query.js index bb8975d85e..3c125d159b 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/simple-query.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/simple-query.js @@ -1,4 +1,5 @@ module.define("org/arangodb/simple-query", function(exports, module) { +/*jshint strict: false */ /*global require, exports */ //////////////////////////////////////////////////////////////////////////////// diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/tutorial.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/tutorial.js index bbafc5f367..f6e216fa9e 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/tutorial.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/tutorial.js @@ -1,5 +1,5 @@ module.define("org/arangodb/tutorial", function(exports, module) { -/*jslint indent: 2, nomen: true, maxlen: 120, sloppy: true, vars: true, white: true, plusplus: true */ +/*jshint strict: false */ /*global require, exports */ //////////////////////////////////////////////////////////////////////////////// @@ -29,9 +29,6 @@ module.define("org/arangodb/tutorial", function(exports, module) { /// @author Copyright 2012-2014, triAGENS GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// -var internal = require("internal"); -var arangosh = require("org/arangodb/arangosh"); - // ----------------------------------------------------------------------------- // --SECTION-- module "org/arangodb/tutorial" // ----------------------------------------------------------------------------- @@ -45,11 +42,11 @@ var lessons = [ text: "This is a user-interactive tutorial on ArangoDB and the ArangoDB shell.\n" + "It will give you a first look into ArangoDB and how it works." }, - { - title: "JavaScript Shell", - text: "On this shell's prompt, you can issue arbitrary JavaScript commands.\n" + - "So you are able to do things like...:\n\n" + - " number = 123;\n" + + { + title: "JavaScript Shell", + text: "On this shell's prompt, you can issue arbitrary JavaScript commands.\n" + + "So you are able to do things like...:\n\n" + + " number = 123;\n" + " number = number * 10;" }, { @@ -60,21 +57,21 @@ var lessons = [ { title: "Printing Results", text: "As you can see, the result of the last command executed is printed automatically. " + - "To explicitly print a value at any other time, there is the print function:\n\n" + + "To explicitly print a value at any other time, there is the print function:\n\n" + " for (i = 0; i < 5; ++i) { print(\"I am a JavaScript shell\"); }" }, { title: "Creating Collections", - text: "ArangoDB is a document database. This means that we store data as documents " + - "(which are similar to JavaScript objects) in so-called 'collections'. " + - "Let's create a collection named 'places' now:\n\n" + - " db._create('places');\n\n" + - "Note: each collection is identified by a unique name. Trying to create a " + + text: "ArangoDB is a document database. This means that we store data as documents " + + "(which are similar to JavaScript objects) in so-called 'collections'. " + + "Let's create a collection named 'places' now:\n\n" + + " db._create('places');\n\n" + + "Note: each collection is identified by a unique name. Trying to create a " + "collection that already exists will produce an error." }, - { + { title: "Displaying Collections", - text: "Now you can take a look at the collection(s) you just created:\n\n" + + text: "Now you can take a look at the collection(s) you just created:\n\n" + " db._collections();\n\n" + "Please note that all collections will be returned, including ArangoDB's pre-defined " + "system collections." @@ -82,12 +79,12 @@ var lessons = [ { title: "Creating Documents", text: "Now we have a collection, but it is stil empty. So let's create some documents!\n\n" + - " db.places.save({ _key : \"foo\", city : \"foo-city\" });\n" + + " db.places.save({ _key : \"foo\", city : \"foo-city\" });\n" + " for (i = 0; i <= 10; i++) { db.places.save({ _key: \"example\" + i, zipcode: i }) };" }, { title: "Displaying All Documents", - text: "You want to take a look at your docs? No problem:\n\n" + + text: "You want to take a look at your docs? No problem:\n\n" + " db.places.toArray();" }, { @@ -95,38 +92,38 @@ var lessons = [ text: "To see how many documents there are in a collection, use the 'count' method:\n\n" + " db.places.count();" }, - { + { title: "Retrieving Single Documents", - text: "As you can see, each document has some meta attributes '_id', '_key' and '_rev'.\n" + + text: "As you can see, each document has some meta attributes '_id', '_key' and '_rev'.\n" + "The '_key' attribute can be used to quickly retrieve a single document from " + - "a collection:\n\n" + - " db.places.document(\"foo\");\n" + + "a collection:\n\n" + + " db.places.document(\"foo\");\n" + " db.places.document(\"example5\");" }, { title: "Retrieving Single Documents", - text: "The '_id' attribute can also be used to retrieve documents using the 'db' object:\n\n" + - " db._document(\"places/foo\");\n" + + text: "The '_id' attribute can also be used to retrieve documents using the 'db' object:\n\n" + + " db._document(\"places/foo\");\n" + " db._document(\"places/example5\");" }, { title: "Modifying Documents", text: "You can modify existing documents. Try to add a new attribute to a document and " + - "verify whether it has been added:\n\n" + - " db._update(\"places/foo\", { zipcode: 39535 });\n" + + "verify whether it has been added:\n\n" + + " db._update(\"places/foo\", { zipcode: 39535 });\n" + " db._document(\"places/foo\");" }, { title: "Document Revisions", - text: "Note that after updating the document, its '_rev' attribute changed automatically.\n" + - "The '_rev' attribute contains a document revision number, and it can be used for " + + text: "Note that after updating the document, its '_rev' attribute changed automatically.\n" + + "The '_rev' attribute contains a document revision number, and it can be used for " + "conditional modifications. Here's an example of how to avoid lost updates in case " + - "multiple clients are accessing the documents in parallel:\n\n" + - " doc = db._document(\"places/example1\");\n" + - " db._update(\"places/example1\", { someValue: 23 });\n" + - " db._update(doc, { someValue: 42 });\n\n" + - "Note that the first update will succeed because it was unconditional. The second " + - "update however is conditional because we're also passing the document's revision " + + "multiple clients are accessing the documents in parallel:\n\n" + + " doc = db._document(\"places/example1\");\n" + + " db._update(\"places/example1\", { someValue: 23 });\n" + + " db._update(doc, { someValue: 42 });\n\n" + + "Note that the first update will succeed because it was unconditional. The second " + + "update however is conditional because we're also passing the document's revision " + "id in the first parameter to _update. As the revision id we're passing to update " + "does not match the document's current revision anymore, the update is rejected." }, @@ -139,22 +136,22 @@ var lessons = [ }, { title: "Searching Documents", - text: "Searching for documents with specific attributes can be done by using the " + + text: "Searching for documents with specific attributes can be done by using the " + "byExample method:\n\n" + " db._create(\"users\");\n" + - " for (i = 0; i < 10; ++i) { " + + " for (i = 0; i < 10; ++i) { " + "db.users.save({ name: \"username\" + i, active: (i % 3 == 0), age: 30 + i }); }\n" + " db.users.byExample({ active: false }).toArray();\n" + " db.users.byExample({ name: \"username3\", active: true }).toArray();\n" }, { title: "Running AQL Queries", - text: "ArangoDB also provides a query language for more complex matching:\n\n" + + text: "ArangoDB also provides a query language for more complex matching:\n\n" + " db._query(\"FOR u IN users FILTER u.active == true && u.age >= 33 " + "RETURN { username: u.name, age: u.age }\").toArray();" }, { - title: "Using Databases", + title: "Using Databases", text: "By default, the ArangoShell connects to the default database. The default database " + "is named '_system'. To create another database, use the '_createDatabase' method of the " + "'db' object. To switch into an existing database, use '_useDatabase'. To get rid of a " + @@ -178,16 +175,16 @@ exports._PRINT = function (context) { /*jslint regexp: true */ function process (text) { - return text.replace(/\n {2}(.+?)(?=\n)/g, + return text.replace(/\n {2}(.+?)(?=\n)/g, "\n " + colors.COLOR_MAGENTA + "$1" + colors.COLOR_RESET); } /*jslint regexp: false */ - + var headline = colors.COLOR_BOLD_BLUE + (index + 1) + ". " + lessons[index].title + colors.COLOR_RESET; context.output += "\n\n" + headline + "\n\n" + - process(lessons[index].text + "\n") + "\n" + + process(lessons[index].text + "\n") + "\n" + next + "\n"; if (index++ >= lessons.length) {