File tree Expand file tree Collapse file tree 2 files changed +48
-36
lines changed
docs/Drivers/JS/GettingStarted Expand file tree Collapse file tree 2 files changed +48
-36
lines changed Original file line number Diff line number Diff line change @@ -33,31 +33,36 @@ npm run dist
3333
3434``` js
3535// Modern JavaScript
36- import {Database , aql } from ' arangojs' ;
36+ import { Database , aql } from " arangojs" ;
3737const db = new Database ();
38- const now = Date .now ();
39- try {
40- const cursor = await db .query (aql` RETURN ${ now} ` );
41- const result = await cursor .next ();
42- // ...
43- } catch (err) {
44- // ...
45- }
38+ (async function () {
39+ const now = Date .now ();
40+ try {
41+ const cursor = await db .query (aql` RETURN ${ now} ` );
42+ const result = await cursor .next ();
43+ // ...
44+ } catch (err) {
45+ // ...
46+ }
47+ })();
4648
4749// or plain old Node-style
48- var arangojs = require (' arangojs' );
50+ var arangojs = require (" arangojs" );
4951var db = new arangojs.Database ();
5052var now = Date .now ();
51- db .query ({
52- query: ' RETURN @arg0' ,
53- bindVars: {arg0: now}
54- }).then (function (cursor ) {
55- return cursor .next ().then (function (result ) {
53+ db
54+ .query ({
55+ query: " RETURN @value" ,
56+ bindVars: { value: now }
57+ })
58+ .then (function (cursor ) {
59+ return cursor .next ().then (function (result ) {
60+ // ...
61+ });
62+ })
63+ .catch (function (err ) {
5664 // ...
5765 });
58- }).catch (function (err ) {
59- // ...
60- });
6166```
6267
6368## Documentation
Original file line number Diff line number Diff line change @@ -150,31 +150,38 @@ When loading the browser build with a script tag make sure to load the polyfill
150150
151151``` js
152152// Modern JavaScript
153- import {Database , aql } from ' arangojs' ;
153+ import { Database , aql } from " arangojs" ;
154154const db = new Database ();
155- const now = Date .now ();
156- try {
157- const cursor = await db .query (aql` RETURN ${ now} ` );
158- const result = await cursor .next ();
159- // ...
160- } catch (err) {
161- // ...
162- }
155+ (async function () {
156+ const now = Date .now ();
157+ try {
158+ const cursor = await db .query (aql`
159+ RETURN ${ now}
160+ ` );
161+ const result = await cursor .next ();
162+ // ...
163+ } catch (err) {
164+ // ...
165+ }
166+ })();
163167
164168// or plain old Node-style
165- var arangojs = require (' arangojs' );
169+ var arangojs = require (" arangojs" );
166170var db = new arangojs.Database ();
167171var now = Date .now ();
168- db .query ({
169- query: ' RETURN @arg0' ,
170- bindVars: {arg0: now}
171- }).then (function (cursor ) {
172- return cursor .next ().then (function (result ) {
172+ db
173+ .query ({
174+ query: " RETURN @value" ,
175+ bindVars: { value: now }
176+ })
177+ .then (function (cursor ) {
178+ return cursor .next ().then (function (result ) {
179+ // ...
180+ });
181+ })
182+ .catch (function (err ) {
173183 // ...
174184 });
175- }).catch (function (err ) {
176- // ...
177- });
178185
179186// Using different databases
180187const db = new Database ({
You can’t perform that action at this time.
0 commit comments