8000 Doc - Sync external repos 2018-09-26 (#6476) · 0xflotus/arangodb@fd1019c · GitHub
[go: up one dir, main page]

Skip to content

Commit fd1019c

Browse files
Simran-Bsleto-it
authored andcommitted
Doc - Sync external repos 2018-09-26 (arangodb#6476)
1 parent ed04451 commit fd1019c

File tree

159 files changed

+1453
-888
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+1453
-888
lines changed

Documentation/Books/Drivers/GO/ConnectionManagement/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- don't edit here, its from https://@github.com/arangodb/go-driver.git / docs/Drivers/ -->
1+
<!-- don't edit here, it's from https://@github.com/arangodb/go-driver.git / docs/Drivers/ -->
22
# ArangoDB GO Driver - Connection Management
33
## Failover
44

Documentation/Books/Drivers/GO/ExampleRequests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- don't edit here, its from https://@github.com/arangodb/go-driver.git / docs/Drivers/ -->
1+
<!-- don't edit here, it's from https://@github.com/arangodb/go-driver.git / docs/Drivers/ -->
22
# ArangoDB GO Driver - Example requests
33

44
## Connecting to ArangoDB

Documentation/Books/Drivers/GO/GettingStarted/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- don't edit here, its from https://@github.com/arangodb/go-driver.git / docs/Drivers/ -->
1+
<!-- don't edit here, it's from https://@github.com/arangodb/go-driver.git / docs/Drivers/ -->
22
# ArangoDB GO Driver - Getting Started
33

44
## Supported versions

Documentation/Books/Drivers/GO/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- don't edit here, its from https://@github.com/arangodb/go-driver.git / docs/Drivers/ -->
1+
<!-- don't edit here, it's from https://@github.com/arangodb/go-driver.git / docs/Drivers/ -->
22
# ArangoDB GO Driver
33

44
The official [ArangoDB](https://arangodb.com) GO Driver

Documentation/Books/Drivers/JS/GettingStarted/README.md

Lines changed: 32 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
<!-- don't edit here, its from https://@github.com/arangodb/arangodbjs.git / docs/Drivers/ -->
1+
<!-- don't edit here, it's from https://@github.com/arangodb/arangodbjs.git / docs/Drivers/ -->
22
# ArangoDB JavaScript Driver - Getting Started
33

44
## Compatibility
55

6-
ArangoJS is compatible with ArangoDB 3.0 and later. **For using ArangoJS with
7-
2.8 or earlier see the upgrade note below.** ArangoJS is tested against the two
8-
most-recent releases of ArangoDB 3 (currently 3.2 and 3.3) as well as the most
9-
recent version of 2.8 and the latest development version.
6+
ArangoJS is compatible with the latest stable version of ArangoDB available at
7+
the time of the driver release.
8+
9+
The [_arangoVersion_ option](../Reference/Database/README.md)
10+
can be used to tell arangojs to target a specific
11+
ArangoDB version. Depending on the version this will enable or disable certain
12+
methods and change behavior to maintain compatibility with the given version.
13+
The oldest version of ArangoDB supported by arangojs when using this option
14+
is 2.8.0 (using `arangoVersion: 20800`).
1015

1116
The yarn/npm distribution of ArangoJS is compatible with Node.js versions 9.x
1217
(latest), 8.x (LTS) and 6.x (LTS). Node.js version support follows
@@ -17,16 +22,10 @@ versions of all modern browsers (Edge, Chrome, Firefox and Safari).
1722

1823
Versions outside this range may be compatible but are not actively supported.
1924

20-
**Upgrade note**: If you want to use arangojs with ArangoDB 2.8 or earlier
21-
remember to set the appropriate `arangoVersion` option (e.g. `20800` for version
22-
2.8.0). The current default value is `30000` (indicating compatibility with
23-
version 3.0.0 and newer). **The driver will behave differently depending on this
24-
value when using APIs that have changed between these versions.**
25-
26-
**Upgrade note for 6.0.0**: All asynchronous functions now return promises and
27-
support for node-style callbacks has been removed. If you are using a version of
28-
Node.js older than Node.js 6.x LTS ("Boron") make sure you replace the native
29-
`Promise` implementation with a substitute like [bluebird](https://github.com/petkaantonov/bluebird)
25+
**Note**: Starting with arangojs 6.0.0, all asynchronous functions return
26+
promises. If you are using a version of Node.js older than Node.js 6.x LTS
27+
("Boron") make sure you replace the native `Promise` implementation with a
28+
substitute like [bluebird](https://github.com/petkaantonov/bluebird)
3029
to avoid a known memory leak in older versions of the V8 JavaScript engine.
3130

3231
## Versions
@@ -35,11 +34,11 @@ The version number of this driver does not indicate supported ArangoDB versions!
3534

3635
This driver uses semantic versioning:
3736

38-
* A change in the bugfix version (e.g. X.Y.0 -> X.Y.1) indicates internal
37+
- A change in the bugfix version (e.g. X.Y.0 -> X.Y.1) indicates internal
3938
changes and should always be safe to upgrade.
40-
* A change in the minor version (e.g. X.1.Z -> X.2.0) indicates additions and
39+
- A change in the minor version (e.g. X.1.Z -> X.2.0) indicates additions and
4140
backwards-compatible changes that should not affect your code.
42-
* A change in the major version (e.g. 1.Y.Z -> 2.0.0) indicates _breaking_
41+
- A change in the major version (e.g. 1.Y.Z -> 2.0.0) indicates _breaking_
4342
changes that require changes in your code to upgrade.
4443

4544
If you are getting weird errors or functions seem to be missing, make sure you
@@ -59,27 +58,6 @@ You can find the documentation for each version by clicking on the corresponding
5958
date on the left in
6059
[the list of version tags](https://github.com/arangodb/arangojs/tags).
6160

62-
## Testing
63-
64-
Run the tests using the `yarn test` or `npm test` commands:
65-
66-
```sh
67-
yarn test
68-
# - or -
69-
npm test
70-
```
71-
72-
By default the tests will be run against a server listening on
73-
`http://localhost:8529` (using username `root` with no password). To
74-
override this, you can set the environment variable `TEST_ARANGODB_URL` to
75-
something different:
76-
77-
```sh
78-
TEST_ARANGODB_URL=http://myserver.local:8530 yarn test
79-
# - or -
80-
TEST_ARANGODB_URL=http://myserver.local:8530 npm test
81-
```
82-
8361
## Install
8462

8563
### With Yarn or NPM
@@ -171,11 +149,10 @@ const db = new Database();
171149
var arangojs = require("arangojs");
172150
var db = new arangojs.Database();
173151
var now = Date.now();
174-
db
175-
.query({
176-
query: "RETURN @value",
177-
bindVars: { value: now }
178-
})
152+
db.query({
153+
query: "RETURN @value",
154+
bindVars: { value: now }
155+
})
179156
.then(function(cursor) {
180157
return cursor.next().then(function(result) {
181158
// ...
@@ -213,7 +190,9 @@ AQL queries without making your code vulnerable to injection attacks.
213190
## Error responses
214191

215192
If arangojs encounters an API error, it will throw an _ArangoError_ with an
216-
[_errorNum_ as defined in the ArangoDB documentation](../../..//Manual/Appendix/ErrorCodes.html) as well as a _code_ and _statusCode_ property indicating the intended and actual HTTP status code of the response.
193+
[_errorNum_ error code](../../..//Manual/Appendix/ErrorCodes.html)
194+
as well as a _code_ and _statusCode_ property indicating the intended and
195+
actual HTTP status code of the response.
217196

218197
For any other error responses (4xx/5xx status code), it will throw an
219198
_HttpError_ error with the status code indicated by the _code_ and _statusCode_ properties.
@@ -224,30 +203,32 @@ not be parsed, a _SyntaxError_ may be thrown instead.
224203
In all of these cases the error object will additionally have a _response_
225204
property containing the server response object.
226205

227-
If the request failed at a network level or the connection was closed without receiving a response, the underlying error will be thrown instead.
206+
If the request failed at a network level or the connection was closed without
207+
receiving a response, the underlying error will be thrown instead.
228208

229209
**Examples**
230210

231211
```js
232212
// Using async/await
233213
try {
234-
const info = await db.createDatabase('mydb');
214+
const info = await db.createDatabase("mydb");
235215
// database created
236216
} catch (err) {
237217
console.error(err.stack);
238218
}
239219

240220
// Using promises with arrow functions
241-
db.createDatabase('mydb')
242-
.then(
221+
db.createDatabase("mydb").then(
243222
info => {
244223
// database created
245224
},
246225
err => console.error(err.stack)
247226
);
248227
```
249228

250-
**Note**: the examples in the remainder of this documentation use async/await
229+
{% hint 'tip' %}
230+
The examples in the remainder of this documentation use `async`/`await`
251231
and other modern language features like multi-line strings and template tags.
252232
When developing for an environment without support for these language features,
253-
just use promises instead as in the above example.
233+
substitute promises for `await` syntax as in the above example.
234+
{% endhint %}

Documentation/Books/Drivers/JS/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- don't edit here, its from https://@github.com/arangodb/arangodbjs.git / docs/Drivers/ -->
1+
<!-- don't edit here, it's from https://@github.com/arangodb/arangodbjs.git / docs/Drivers/ -->
22
# ArangoDB JavaScript Driver
33

44
The official ArangoDB low-level JavaScript client.
@@ -11,6 +11,6 @@ instead; specifically the `db` object exported by the `@arangodb` module. The
1111
JavaScript driver is **only** meant to be used when accessing ArangoDB from
1212
**outside** the database.
1313

14-
* [Getting Started](GettingStarted/README.md)
15-
* [Reference](Reference/README.md)
16-
* [Changelog](https://github.com/arangodb/arangojs/blob/master/CHANGELOG.md#readme)
14+
- [Getting Started](GettingStarted/README.md)
15+
- [Reference](Reference/README.md)
16+
- [Changelog](https://github.com/arangodb/arangojs/blob/master/CHANGELOG.md#readme)
Lines changed: 111 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- don't edit here, its from https://@github.com/arangodb/arangodbjs.git / docs/Drivers/ -->
1+
<!-- don't edit here, it's from https://@github.com/arangodb/arangodbjs.git / docs/Drivers/ -->
22
# Bulk importing documents
33

44
This function implements the
@@ -12,90 +12,140 @@ Bulk imports the given _data_ into the collection.
1212

1313
**Arguments**
1414

15-
* **data**: `Array<Array<any>> | Array<Object>`
15+
- **data**: `Array | Buffer | string`
1616

17-
The data to import. This can be an array of documents:
17+
The data to import. Depending on the _type_ option this can be any of the
18+
following:
1819

19-
```js
20-
[
21-
{key1: value1, key2: value2}, // document 1
22-
{key1: value1, key2: value2}, // document 2
23-
...
24-
]< 10000 /div>
25-
```
20+
For type `"documents"` or `"auto"`:
2621

27-
Or it can be an array of value arrays following an array of keys.
22+
- an array of documents, e.g.
2823

29-
```js
30-
[
31-
['key1', 'key2'], // key names
32-
[value1, value2], // document 1
33-
[value1, value2], // document 2
34-
...
35-
]
36-
```
37-
38-
* **opts**: `Object` (optional) If _opts_ is set, it must be an object with any
24+
```json
25+
[
26+
{ "_key": "banana", "color": "yellow" },
27+
{ "_key": "peach", "color": "pink" }
28+
]
29+
```
30+
31+
- a string or buffer containing one JSON document per line, e.g.
32+
33+
```
34+
{"_key":"banana","color":"yellow"}
35+
{"_key":"peach","color":"pink"}
36+
```
37+
38+
For type `"array"` or `"auto"`:
39+
40+
- a string or buffer containing a JSON array of documents, e.g.
41+
42+
```json
43+
[
44+
{ "_key": "banana", "color": "yellow" },
45+
{ "_key": "peach", "color": "pink" }
46+
]
47+
```
48+
49+
For type `null`:
50+
51+
- an array containing an array of keys followed by arrays of values, e.g.
52+
53+
```
54+
[
55+
["_key", "color"],
56+
["banana", "yellow"],
57+
["peach", "pink"]
58+
]
59+
```
60+
61+
- a string or buffer containing a JSON array of keys followed by
62+
one JSON array of values per line, e.g.
63+
64+
```
65+
["_key", "color"]
66+
["banana", "yellow"]
67+
["peach", "pink"]
68+
```
69+
70+
- **opts**: `Object` (optional) If _opts_ is set, it must be an object with any
3971
of the following properties:
4072

41-
* **waitForSync**: `boolean` (Default: `false`)
73+
- **type**: `string | null` (Default: `"auto"`)
74+
75+
Indicates which format the data uses.
76+
Can be `"documents"`, `"array"` or `"auto"`.
77+
Use `null` to explicitly set no type.
78+
79+
- **fromPrefix**: `string` (optional)
80+
81+
Prefix to prepend to `_from` attributes.
82+
83+
- **toPrefix**: `string` (optional)
84+
85+
Prefix to prepend to `_to` attributes.
86+
87+
- **overwrite**: `boolean` (Default: `false`)
88+
89+
If set to `true`, the collection is truncated before the data is imported.
90+
91+
- **waitForSync**: `boolean` (Default: `false`)
4292

4393
Wait until the documents have been synced to disk.
4494

45-
* **details**: `boolean` (Default: `false`)
95+
- **onDuplicate**: `string` (Default: `"error"`)
4696

47-
Whether the response should contain additional details about documents that
48-
could not be imported.false\*.
97+
Controls behavior when a unique constraint is violated.
98+
Can be `"error"`, `"update"`, `"replace"` or `"ignore"`.
99+
100+
- **complete**: `boolean` (Default: `false`)
49101

50-
* **type**: `string` (Default: `"auto"`)
102+
If set to `true`, the import will abort if any error occurs.
51103

52-
Indicates which format the data uses. Can be `"documents"`, `"array"` or
53-
`"auto"`.
104+
- **details**: `boolean` (Default: `false`)
54105

55-
If _data_ is a JavaScript array, it will be transmitted as a line-delimited JSON
56-
stream. If _opts.type_ is set to `"array"`, it will be transmitted as regular
57-
JSON instead. If _data_ is a string, it will be transmitted as it is without any
58-
processing.
106+
Whether the response should contain additional details about documents that
107+
could not be imported.
59108

60-
For more information on the _opts_ object, see
61-
[the HTTP API documentation for bulk imports](../../../..//HTTP/BulkImports/ImportingSelfContained.html).
109+
For more information on the _opts_ object, see the
110+
[HTTP API documentation for bulk imports](../../../..//HTTP/BulkImports/index.html).
62111

63112
**Examples**
64113

65114
```js
66115
const db = new Database();
67-
const collection = db.collection('users');
116+
const collection = db.collection("users");
68117

69-
// document stream
70-
const result = await collection.import([
71-
{username: 'admin', password: 'hunter2'},
72-
{username: 'jcd', password: 'bionicman'},
73-
{username: 'jreyes', password: 'amigo'},
74-
{username: 'ghermann', password: 'zeitgeist'}
75-
]);
76-
assert.equal(result.created, 4);
118+
const result = await collection.import(
119+
[
120+
{ username: "jcd", password: "bionicman" },
121+
{ username: "jreyes", password: "amigo" },
122+
{ username: "ghermann", password: "zeitgeist" }
123+
],
124+
{ type: "documents" } // optional
125+
);
77126

78127
// -- or --
79128

80-
// array stream with header
81-
const result = await collection.import([
82-
['username', 'password'], // keys
83-
['admin', 'hunter2'], // row 1
84-
['jcd', 'bionicman'], // row 2
85-
['jreyes', 'amigo'],
86-
['ghermann', 'zeitgeist']
87-
]);
88-
assert.equal(result.created, 4);
129+
const buf = fs.readFileSync("dx_users.json");
130+
// [
131+
// {"username": "jcd", "password": "bionicman"},
132+
// {"username": "jreyes", "password": "amigo"},
133+
// {"username": "ghermann", "password": "zeitgeist"}
134+
// ]
135+
const result = await collection.import(
136+
buf,
137+
{ type: "array" } // optional
138+
);
89139

90140
// -- or --
91141

92-
// raw line-delimited JSON array stream with header
93-
const result = await collection.import([
94-
'["username", "password"]',
95-
'["admin", "hunter2"]',
96-
'["jcd", "bionicman"]',
97-
'["jreyes", "amigo"]',
98-
'["ghermann", "zeitgeist"]'
99-
].join('\r\n') + '\r\n');
100-
assert.equal(result.created, 4);
142+
const result = await collection.import(
143+
[
144+
["username", "password"],
145+
["jcd", "bionicman"],
146+
["jreyes", "amigo"],
147+
["ghermann", "zeitgeist"]
148+
],
149+
{ type: null } // required
150+
);
101151
```

0 commit comments

Comments
 (0)
0