mirror of https://gitee.com/bigwinds/arangodb
added derived files
This commit is contained in:
parent
6f9376e264
commit
4fe43c5b49
|
@ -1,3 +1,4 @@
|
|||
/*jshint maxlen: 200 */
|
||||
/*global require */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -5,6 +6,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
var internal = require("internal");
|
||||
|
||||
internal.errors = {
|
||||
|
|
|
@ -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});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/*jshint strict: false */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief monkey-patches to built-in prototypes
|
||||
///
|
||||
|
|
|
@ -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]);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -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__);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
module.define("org/arangodb/aql/functions", function(exports, module) {
|
||||
/*jshint strict: false */
|
||||
/*global require, exports */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
module.define("org/arangodb/arango-collection-common", function(exports, module) {
|
||||
/*jshint strict: false, unused: false */
|
||||
/*global require */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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()));
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
module.define("org/arangodb/arango-database", function(exports, module) {
|
||||
/*jshint strict: false */
|
||||
/*global require, exports */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
module.define("org/arangodb/arango-query-cursor", function(exports, module) {
|
||||
/*jshint strict: false */
|
||||
/*global require, exports */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
module.define("org/arangodb/arango-statement", function(exports, module) {
|
||||
/*jshint strict: false */
|
||||
/*global require, exports */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
module.define("org/arangodb/arangosh", function(exports, module) {
|
||||
/*jshint strict: false */
|
||||
/*global require, exports */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
module.define("org/arangodb/graph-blueprint", function(exports, module) {
|
||||
/*jshint strict: false */
|
||||
/*global require, exports */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
module.define("org/arangodb/graph-common", function(exports, module) {
|
||||
/*jshint strict: false */
|
||||
/*global require, exports */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
module.define("org/arangodb/graph", function(exports, module) {
|
||||
/*jshint strict: false */
|
||||
/*global require, exports */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
module.define("org/arangodb/graph/traversal", function(exports, module) {
|
||||
/*jshint strict: false, unused: false */
|
||||
/*global require, exports, ArangoClusterComm */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
module.define("org/arangodb/simple-query-common", function(exports, module) {
|
||||
/*jshint strict: false */
|
||||
/*global require, exports */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
module.define("org/arangodb/simple-query", function(exports, module) {
|
||||
/*jshint strict: false */
|
||||
/*global require, exports */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue