File tree Expand file tree Collapse file tree 4 files changed +57
-0
lines changed Expand file tree Collapse file tree 4 files changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ .DS_Store
2
+ * .log
3
+ node_modules /
4
+ yarn.lock
5
+ package-lock.json
Original file line number Diff line number Diff line change
1
+ # RethinkDB client example
2
+
3
+ 1 . Clone the project: ``
4
+ 1 . Open file ` app.js ` and update the configuration
5
+ 1 . Install dependencies: ` npm install `
6
+ 1 . Run this example: ` npm run start `
Original file line number Diff line number Diff line change
1
+ const r = require ( 'rethinkdbdash' ) ( {
2
+ host : 'XXXXXX.stackhero-network.com' , // This is the host you'll find on Stackhero console
3
+ port : 29015 ,
4
+ user : 'admin' ,
5
+ password : 'XXXXXXXXXXXXX' , // This is the admin password you've defined on Stackhero console
6
+ ssl : true ,
7
+ silent : true
8
+ } ) ;
9
+
10
+ ( async ( ) => {
11
+
12
+ console . log ( 'Getting list of tables' ) ;
13
+ const tables = await r . tableList ( ) ;
14
+
15
+ if ( tables . length ) {
16
+ console . log ( 'The server has those tables: ' + tables . join ( ) ) ;
17
+ }
18
+
19
+ if ( tables . indexOf ( 'datasTest' ) === - 1 ) {
20
+ console . log ( 'Creating table "datasTest"' ) ;
21
+ await r . tableCreate ( 'datasTest' ) . run ( ) ;
22
+ }
23
+
24
+ console . log ( 'Inserting datas into table datasTest' ) ;
25
+ await r . table ( 'datasTest' )
26
+ . insert ( { test : 'ok' } )
27
+ . run ( ) ;
28
+
29
+ console . log ( 'Getting datas in table datasTest' ) ;
30
+ const datas = await r . table ( 'datasTest' ) . run ( ) ;
31
+ console . log ( datas ) ;
32
+
33
+ console . log ( 'Close connection' ) ;
34
+ r . getPoolMaster ( ) . drain ( ) ;
35
+
36
+ console . log ( 'All done, your RethinkDB is up and running :)' ) ;
37
+ } ) ( ) ;
38
+
Original file line number Diff line number Diff line change
1
+ {
2
+ "scripts" : {
3
+ "start" : " node app.js"
4
+ },
5
+ "dependencies" : {
6
+ "rethinkdbdash" : " ^2.3.31"
7
+ }
8
+ }
You can’t perform that action at this time.
0 commit comments