mirror of https://gitee.com/bigwinds/arangodb
Replace more require('internal') by require('@arangodb') where possible
This commit is contained in:
parent
615f408b10
commit
963066e42d
|
@ -139,7 +139,7 @@ To do so, use the *hasNext* and *next* methods of the cursor:
|
|||
@EXAMPLE_ARANGOSH_OUTPUT{05_workWithAQL_statements4}
|
||||
~var stmt = db._createStatement( { "query": "FOR i IN [ 1, 2 ] RETURN i * 2" } );
|
||||
~var c = stmt.execute();
|
||||
while (c.hasNext()) { require("internal").print(c.next()); }
|
||||
while (c.hasNext()) { require("@arangodb").print(c.next()); }
|
||||
@END_EXAMPLE_ARANGOSH_OUTPUT
|
||||
@endDocuBlock 05_workWithAQL_statements4
|
||||
|
||||
|
@ -185,7 +185,7 @@ or
|
|||
~stmt.bind("one", 1);
|
||||
~stmt.bind("two", 2);
|
||||
~var c = stmt.execute();
|
||||
while (c.hasNext()) { require("internal").print(c.next()); }
|
||||
while (c.hasNext()) { require("@arangodb").print(c.next()); }
|
||||
@END_EXAMPLE_ARANGOSH_OUTPUT
|
||||
@endDocuBlock 05_workWithAQL_statements7
|
||||
|
||||
|
|
|
@ -13,13 +13,12 @@ For example, you could put the following into the *.arangosh.rc* file in your ho
|
|||
directory:
|
||||
|
||||
```js
|
||||
// "var" keyword omitted intentionally...
|
||||
// "var" keyword avoided intentionally...
|
||||
// otherwise "timed" would not survive the scope of this script
|
||||
global.timed = function (cb) {
|
||||
var internal = require("internal");
|
||||
var start = internal.time();
|
||||
console.time("callback");
|
||||
cb();
|
||||
internal.print("execution took: ", internal.time() - start);
|
||||
console.timeEnd("callback");
|
||||
};
|
||||
```
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ you can paste multiple lines into arangosh, given the first line ends with an op
|
|||
@startDocuBlockInline shellPaste
|
||||
@EXAMPLE_ARANGOSH_OUTPUT{shellPaste}
|
||||
|for (var i = 0; i < 10; i ++) {
|
||||
| require("internal").print("Hello world " + i + "!\n");
|
||||
| require("@arangodb").print("Hello world " + i + "!\n");
|
||||
}
|
||||
@END_EXAMPLE_ARANGOSH_OUTPUT
|
||||
@endDocuBlock shellPaste
|
||||
|
|
|
@ -28,7 +28,7 @@ uses resources, you may want to increase `period` (and not forget to remove it..
|
|||
|tasks.register({
|
||||
| id: "mytask-1",
|
||||
| name: "this is a sample task to spawn a slow aql query",
|
||||
| command: "require('internal').db._query('" + theQuery + "');"
|
||||
| command: "require('@arangodb').db._query('" + theQuery + "');"
|
||||
});
|
||||
|~ while (true) {
|
||||
|~ require("internal").wait(1);
|
||||
|
|
|
@ -25,7 +25,7 @@ For example, to determine which edges are linked to the *world* vertex, we can u
|
|||
|
||||
```js
|
||||
db.e.inEdges('v/world').forEach(function(edge) {
|
||||
require("internal").print(edge._from, "->", edge.type, "->", edge._to);
|
||||
require("@arangodb").print(edge._from, "->", edge.type, "->", edge._to);
|
||||
});
|
||||
```
|
||||
|
||||
|
@ -46,7 +46,7 @@ the linked vertices, we can use each edges' *_from* and *_to* attributes as foll
|
|||
|
||||
```js
|
||||
db.e.inEdges('v/world').forEach(function(edge) {
|
||||
require("internal").print(db._document(edge._from).name, "->", edge.type, "->", db._document(edge._to).name);
|
||||
require("@arangodb").print(db._document(edge._from).name, "->", edge.type, "->", db._document(edge._to).name);
|
||||
});
|
||||
```
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ Finally, we can print the contents of the *results* object, limited to the visit
|
|||
We will only print the name and type of each visited vertex for brevity:
|
||||
|
||||
```js
|
||||
require("internal").print(result.visited.vertices.map(function(vertex) {
|
||||
require("@arangodb").print(result.visited.vertices.map(function(vertex) {
|
||||
return vertex.name + " (" + vertex.type + ")";
|
||||
}));
|
||||
```
|
||||
|
@ -76,7 +76,7 @@ var result = {
|
|||
var traverser = new traversal.Traverser(config);
|
||||
traverser.traverse(result, startVertex);
|
||||
|
||||
require("internal").print(result.visited.vertices.map(function(vertex) {
|
||||
require("@arangodb").print(result.visited.vertices.map(function(vertex) {
|
||||
return vertex.name + " (" + vertex.type + ")";
|
||||
}));
|
||||
```
|
||||
|
@ -162,7 +162,7 @@ var result = {
|
|||
var traverser = new traversal.Traverser(config);
|
||||
traverser.traverse(result, startVertex);
|
||||
|
||||
require("internal").print(result.visited.vertices.map(function(vertex) {
|
||||
require("@arangodb").print(result.visited.vertices.map(function(vertex) {
|
||||
return vertex.name + " (" + vertex.type + ")";
|
||||
}));
|
||||
```
|
||||
|
@ -211,7 +211,7 @@ var result = {
|
|||
var traverser = new traversal.Traverser(config);
|
||||
traverser.traverse(result, startVertex);
|
||||
|
||||
require("internal").print(result.visited.vertices.map(function(vertex) {
|
||||
require("@arangodb").print(result.visited.vertices.map(function(vertex) {
|
||||
return vertex.name + " (" + vertex.type + ")";
|
||||
}));
|
||||
```
|
||||
|
@ -388,7 +388,7 @@ var config = {
|
|||
filter: traversal.visitAllFilter,
|
||||
expander: traversal.inboundExpander,
|
||||
visitor: function (config, result, vertex, path) {
|
||||
require("internal").print("visiting vertex", vertex.name);
|
||||
require("@arangodb").print("visiting vertex", vertex.name);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -447,7 +447,7 @@ do not have any further connected edges):
|
|||
```js
|
||||
config.visitor = function (config, result, vertex, path, connected) {
|
||||
if (connected && connected.length === 0) {
|
||||
require("internal").print("found a leaf-node: ", vertex);
|
||||
require("@arangodb").print("found a leaf-node: ", vertex);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
@ -24,7 +24,7 @@ Some example that uses collections:
|
|||
read: [ "c1", "c2" ]
|
||||
},
|
||||
action: function (params) {
|
||||
var db = require('internal').db;
|
||||
var db = require('@arangodb').db;
|
||||
var doc = db.c1.document(params['c1Key']);
|
||||
db.users.save(doc);
|
||||
doc = db.c2.document(params['c2Key']);
|
||||
|
|
|
@ -35,7 +35,7 @@ If the post body is not accurate, a *HTTP 400* is returned.
|
|||
// Note: prints stuff if server is running in non-daemon mode.
|
||||
var sampleTask = {
|
||||
name: "SampleTask",
|
||||
command: "(function(params) { require('internal').print(params); })(params)",
|
||||
command: "(function(params) { require('@arangodb').print(params); })(params)",
|
||||
params: { "foo": "bar", "bar": "foo"},
|
||||
period: 2
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ If the task *id* already exists or the rest body is not accurate, *HTTP 400* is
|
|||
var sampleTask = {
|
||||
id: "SampleTask",
|
||||
name: "SampleTask",
|
||||
command: "(function(params) { require('internal').print(params); })(params)",
|
||||
command: "(function(params) { require('@arangodb').print(params); })(params)",
|
||||
params: { "foo": "bar", "bar": "foo"},
|
||||
period: 2
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ Executing a transaction on a single collection
|
|||
collections: {
|
||||
write : "products"
|
||||
},
|
||||
action: "function () { var db = require('internal').db; db.products.save({}); return db.products.count(); }"
|
||||
action: "function () { var db = require('@arangodb').db; db.products.save({}); return db.products.count(); }"
|
||||
};
|
||||
|
||||
var response = logCurlRequest('POST', url, body);
|
||||
|
@ -132,7 +132,7 @@ Executing a transaction using multiple collections
|
|||
},
|
||||
action: (
|
||||
"function () {" +
|
||||
"var db = require('internal').db;" +
|
||||
"var db = require('@arangodb').db;" +
|
||||
"db.products.save({});" +
|
||||
"db.materials.save({});" +
|
||||
"return 'worked!';" +
|
||||
|
@ -161,7 +161,7 @@ Aborting a transaction due to an internal error
|
|||
},
|
||||
action : (
|
||||
"function () {" +
|
||||
"var db = require('internal').db;" +
|
||||
"var db = require('@arangodb').db;" +
|
||||
"db.products.save({ _key: 'abc'});" +
|
||||
"db.products.save({ _key: 'abc'});" +
|
||||
"}"
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
*/
|
||||
|
||||
var internal = require('internal');
|
||||
var print = require('internal').print;
|
||||
var print = require('@arangodb').print;
|
||||
var errors = require("@arangodb").errors;
|
||||
var time = require("internal").time;
|
||||
var fs = require('fs');
|
||||
|
|
Loading…
Reference in New Issue