1
0
Fork 0

added derived files

This commit is contained in:
Jan Steemann 2014-09-08 10:59:07 +02:00
parent 6f9376e264
commit 4fe43c5b49
22 changed files with 82 additions and 58 deletions

View File

@ -1,3 +1,4 @@
/*jshint maxlen: 200 */
/*global require */ /*global require */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -5,6 +6,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
(function () { (function () {
"use strict";
var internal = require("internal"); var internal = require("internal");
internal.errors = { internal.errors = {

View File

@ -1,3 +1,4 @@
/*jshint -W051: true */
/*global require, SYS_GETLINE, SYS_LOG, jqconsole */ /*global require, SYS_GETLINE, SYS_LOG, jqconsole */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -28,8 +29,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
(function () { (function () {
// cannot use strict here as we are going to delete globals /*jshint strict: false */
var exports = require("console"); var exports = require("console");
var sprintf = require("internal").sprintf; var sprintf = require("internal").sprintf;
@ -112,7 +112,7 @@
else if (arg === null) { else if (arg === null) {
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}); arg = inspect(arg, {prettyPrint: false});
} }
} }

View File

@ -1,3 +1,5 @@
/*jshint strict: false */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief monkey-patches to built-in prototypes /// @brief monkey-patches to built-in prototypes
/// ///

View File

@ -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" /// @brief module "internal"
@ -309,7 +310,7 @@
var i = 0; var i = 0;
return format.replace(/%[dfs]/, function (match) { return format.replace(/%[dfs]/, function () {
return String(arguments[++i]); return String(arguments[++i]);
}); });
}; };

View File

@ -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 /// @brief ArangoShell client API
@ -36,6 +37,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function start_pager () { function start_pager () {
"use strict";
var internal = require("internal"); var internal = require("internal");
internal.startPager(); internal.startPager();
} }
@ -45,6 +47,7 @@ function start_pager () {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function stop_pager () { function stop_pager () {
"use strict";
var internal = require("internal"); var internal = require("internal");
internal.stopPager(); internal.stopPager();
} }
@ -54,6 +57,7 @@ function stop_pager () {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function help () { function help () {
"use strict";
var internal = require("internal"); var internal = require("internal");
var arangodb = require("org/arangodb"); var arangodb = require("org/arangodb");
var arangosh = require("org/arangodb/arangosh"); var arangosh = require("org/arangodb/arangosh");
@ -71,6 +75,7 @@ function help () {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function clear () { function clear () {
"use strict";
var internal = require("internal"); var internal = require("internal");
var i; var i;
var result = ''; var result = '';
@ -85,8 +90,8 @@ function clear () {
/// @brief global 'console' /// @brief global 'console'
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (console === undefined) { if (typeof console === 'undefined') {
var console = require("console"); console = require("console");
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -134,6 +139,7 @@ var tutorial = require("org/arangodb/tutorial");
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
(function() { (function() {
"use strict";
var internal = require("internal"); var internal = require("internal");
var arangosh = require("org/arangodb/arangosh"); var arangosh = require("org/arangodb/arangosh");
var special; var special;
@ -168,6 +174,7 @@ var tutorial = require("org/arangodb/tutorial");
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
(function () { (function () {
/*jshint strict: false */
var __special__; var __special__;
try { try {
@ -185,6 +192,7 @@ var tutorial = require("org/arangodb/tutorial");
var __rcf__ = __fs__.join(__fs__.home(), ".arangosh.rc"); var __rcf__ = __fs__.join(__fs__.home(), ".arangosh.rc");
if (__fs__.exists(__rcf__)) { if (__fs__.exists(__rcf__)) {
/*jshint evil: true */
var __content__ = __fs__.read(__rcf__); var __content__ = __fs__.read(__rcf__);
eval(__content__); eval(__content__);
} }

View File

@ -1,4 +1,5 @@
module.define("org/arangodb/aql/functions", function(exports, module) { module.define("org/arangodb/aql/functions", function(exports, module) {
/*jshint strict: false */
/*global require, exports */ /*global require, exports */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,4 +1,5 @@
module.define("org/arangodb/arango-collection-common", function(exports, module) { module.define("org/arangodb/arango-collection-common", function(exports, module) {
/*jshint strict: false, unused: false */
/*global require */ /*global require */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,4 +1,5 @@
module.define("org/arangodb/arango-collection", function(exports, module) { module.define("org/arangodb/arango-collection", function(exports, module) {
/*jshint strict: false */
/*global require, exports */ /*global require, exports */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -159,7 +160,7 @@ ArangoCollection.prototype._documenturl = function (id) {
/// @brief return the base url for collection index usage /// @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())); return this._prefixurl("/_api/index?collection=" + encodeURIComponent(this.name()));
}; };

View File

@ -1,4 +1,5 @@
module.define("org/arangodb/arango-database", function(exports, module) { module.define("org/arangodb/arango-database", function(exports, module) {
/*jshint strict: false */
/*global require, exports */ /*global require, exports */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,4 +1,5 @@
module.define("org/arangodb/arango-query-cursor", function(exports, module) { module.define("org/arangodb/arango-query-cursor", function(exports, module) {
/*jshint strict: false */
/*global require, exports */ /*global require, exports */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,6 @@
module.define("org/arangodb/arango-statement-common", function(exports, module) { module.define("org/arangodb/arango-statement-common", function(exports, module) {
/*global require, exports */ /*jshint strict: false */
/*global exports */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief Arango statements /// @brief Arango statements
@ -190,7 +191,7 @@ ArangoStatement.prototype.setOptions = function (value) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ArangoStatement.prototype.setQuery = function (query) { ArangoStatement.prototype.setQuery = function (query) {
this._query = query; this._query = (query && typeof query.toAQL === 'function') ? query.toAQL() : query;
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,4 +1,5 @@
module.define("org/arangodb/arango-statement", function(exports, module) { module.define("org/arangodb/arango-statement", function(exports, module) {
/*jshint strict: false */
/*global require, exports */ /*global require, exports */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,4 +1,5 @@
module.define("org/arangodb/arangosh", function(exports, module) { module.define("org/arangodb/arangosh", function(exports, module) {
/*jshint strict: false */
/*global require, exports */ /*global require, exports */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,6 @@
module.define("org/arangodb/general-graph", function(exports, module) { 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 /// @brief Graph functionality
@ -1721,7 +1722,7 @@ var _create = function (graphName, edgeDefinitions, orphanCollections, options)
); );
try { try {
var g = gdb.document(graphName); gdb.document(graphName);
} catch (e) { } catch (e) {
if (e.errorNum !== errors.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code) { if (e.errorNum !== errors.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code) {
throw e; throw e;

View File

@ -1,4 +1,5 @@
module.define("org/arangodb/graph-blueprint", function(exports, module) { module.define("org/arangodb/graph-blueprint", function(exports, module) {
/*jshint strict: false */
/*global require, exports */ /*global require, exports */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,4 +1,5 @@
module.define("org/arangodb/graph-common", function(exports, module) { module.define("org/arangodb/graph-common", function(exports, module) {
/*jshint strict: false */
/*global require, exports */ /*global require, exports */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,4 +1,5 @@
module.define("org/arangodb/graph", function(exports, module) { module.define("org/arangodb/graph", function(exports, module) {
/*jshint strict: false */
/*global require, exports */ /*global require, exports */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,4 +1,5 @@
module.define("org/arangodb/graph/traversal", function(exports, module) { module.define("org/arangodb/graph/traversal", function(exports, module) {
/*jshint strict: false, unused: false */
/*global require, exports, ArangoClusterComm */ /*global require, exports, ArangoClusterComm */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
module.define("org/arangodb/is", function(exports, module) { module.define("org/arangodb/is", function(exports, module) {
/*global require, exports */ /*global exports */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief Check if something is something /// @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 // Check if a value is not undefined or null
var existy = function (x) { var existy = function (x) {
"use strict"; "use strict";
// This is != on purpose to also check for undefined return x !== null && x !== undefined;
return x != null;
}; };
// Check if a value is undefined or null // Check if a value is undefined or null

View File

@ -1,4 +1,5 @@
module.define("org/arangodb/simple-query-common", function(exports, module) { module.define("org/arangodb/simple-query-common", function(exports, module) {
/*jshint strict: false */
/*global require, exports */ /*global require, exports */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,4 +1,5 @@
module.define("org/arangodb/simple-query", function(exports, module) { module.define("org/arangodb/simple-query", function(exports, module) {
/*jshint strict: false */
/*global require, exports */ /*global require, exports */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
module.define("org/arangodb/tutorial", function(exports, module) { 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 */ /*global require, exports */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -29,9 +29,6 @@ module.define("org/arangodb/tutorial", function(exports, module) {
/// @author Copyright 2012-2014, triAGENS GmbH, Cologne, Germany /// @author Copyright 2012-2014, triAGENS GmbH, Cologne, Germany
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var internal = require("internal");
var arangosh = require("org/arangodb/arangosh");
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- module "org/arangodb/tutorial" // --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" + 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." "It will give you a first look into ArangoDB and how it works."
}, },
{ {
title: "JavaScript Shell", title: "JavaScript Shell",
text: "On this shell's prompt, you can issue arbitrary JavaScript commands.\n" + text: "On this shell's prompt, you can issue arbitrary JavaScript commands.\n" +
"So you are able to do things like...:\n\n" + "So you are able to do things like...:\n\n" +
" number = 123;\n" + " number = 123;\n" +
" number = number * 10;" " number = number * 10;"
}, },
{ {
@ -60,21 +57,21 @@ var lessons = [
{ {
title: "Printing Results", title: "Printing Results",
text: "As you can see, the result of the last command executed is printed automatically. " + 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\"); }" " for (i = 0; i < 5; ++i) { print(\"I am a JavaScript shell\"); }"
}, },
{ {
title: "Creating Collections", title: "Creating Collections",
text: "ArangoDB is a document database. This means that we store data as documents " + text: "ArangoDB is a document database. This means that we store data as documents " +
"(which are similar to JavaScript objects) in so-called 'collections'. " + "(which are similar to JavaScript objects) in so-called 'collections'. " +
"Let's create a collection named 'places' now:\n\n" + "Let's create a collection named 'places' now:\n\n" +
" db._create('places');\n\n" + " db._create('places');\n\n" +
"Note: each collection is identified by a unique name. Trying to create a " + "Note: each collection is identified by a unique name. Trying to create a " +
"collection that already exists will produce an error." "collection that already exists will produce an error."
}, },
{ {
title: "Displaying Collections", 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" + " db._collections();\n\n" +
"Please note that all collections will be returned, including ArangoDB's pre-defined " + "Please note that all collections will be returned, including ArangoDB's pre-defined " +
"system collections." "system collections."
@ -82,12 +79,12 @@ var lessons = [
{ {
title: "Creating Documents", title: "Creating Documents",
text: "Now we have a collection, but it is stil empty. So let's create some documents!\n\n" + 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 }) };" " for (i = 0; i <= 10; i++) { db.places.save({ _key: \"example\" + i, zipcode: i }) };"
}, },
{ {
title: "Displaying All Documents", 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();" " 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" + text: "To see how many documents there are in a collection, use the 'count' method:\n\n" +
" db.places.count();" " db.places.count();"
}, },
{ {
title: "Retrieving Single Documents", 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 " + "The '_key' attribute can be used to quickly retrieve a single document from " +
"a collection:\n\n" + "a collection:\n\n" +
" db.places.document(\"foo\");\n" + " db.places.document(\"foo\");\n" +
" db.places.document(\"example5\");" " db.places.document(\"example5\");"
}, },
{ {
title: "Retrieving Single Documents", title: "Retrieving Single Documents",
text: "The '_id' attribute can also be used to retrieve documents using the 'db' object:\n\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/foo\");\n" +
" db._document(\"places/example5\");" " db._document(\"places/example5\");"
}, },
{ {
title: "Modifying Documents", title: "Modifying Documents",
text: "You can modify existing documents. Try to add a new attribute to a document and " + text: "You can modify existing documents. Try to add a new attribute to a document and " +
"verify whether it has been added:\n\n" + "verify whether it has been added:\n\n" +
" db._update(\"places/foo\", { zipcode: 39535 });\n" + " db._update(\"places/foo\", { zipcode: 39535 });\n" +
" db._document(\"places/foo\");" " db._document(\"places/foo\");"
}, },
{ {
title: "Document Revisions", title: "Document Revisions",
text: "Note that after updating the document, its '_rev' attribute changed automatically.\n" + 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 " + "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 " + "conditional modifications. Here's an example of how to avoid lost updates in case " +
"multiple clients are accessing the documents in parallel:\n\n" + "multiple clients are accessing the documents in parallel:\n\n" +
" doc = db._document(\"places/example1\");\n" + " doc = db._document(\"places/example1\");\n" +
" db._update(\"places/example1\", { someValue: 23 });\n" + " db._update(\"places/example1\", { someValue: 23 });\n" +
" db._update(doc, { someValue: 42 });\n\n" + " db._update(doc, { someValue: 42 });\n\n" +
"Note that the first update will succeed because it was unconditional. The second " + "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 " + "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 " + "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." "does not match the document's current revision anymore, the update is rejected."
}, },
@ -139,22 +136,22 @@ var lessons = [
}, },
{ {
title: "Searching Documents", 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" + "byExample method:\n\n" +
" db._create(\"users\");\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.save({ name: \"username\" + i, active: (i % 3 == 0), age: 30 + i }); }\n" +
" db.users.byExample({ active: false }).toArray();\n" + " db.users.byExample({ active: false }).toArray();\n" +
" db.users.byExample({ name: \"username3\", active: true }).toArray();\n" " db.users.byExample({ name: \"username3\", active: true }).toArray();\n"
}, },
{ {
title: "Running AQL Queries", 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 " + " db._query(\"FOR u IN users FILTER u.active == true && u.age >= 33 " +
"RETURN { username: u.name, age: u.age }\").toArray();" "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 " + 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 " + "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 " + "'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 */ /*jslint regexp: true */
function process (text) { 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); "\n " + colors.COLOR_MAGENTA + "$1" + colors.COLOR_RESET);
} }
/*jslint regexp: false */ /*jslint regexp: false */
var headline = colors.COLOR_BOLD_BLUE + (index + 1) + ". " + lessons[index].title + colors.COLOR_RESET; var headline = colors.COLOR_BOLD_BLUE + (index + 1) + ". " + lessons[index].title + colors.COLOR_RESET;
context.output += "\n\n" + context.output += "\n\n" +
headline + "\n\n" + headline + "\n\n" +
process(lessons[index].text + "\n") + "\n" + process(lessons[index].text + "\n") + "\n" +
next + "\n"; next + "\n";
if (index++ >= lessons.length) { if (index++ >= lessons.length) {