简体   繁体   中英

Arngodb, Arangojs error while retriving data

I get this error when trying to retrieve data from arangodb.

TypeError: db.database is not a function

var Database = require('arangojs');
var db = new Database({url:'http://127.0.0.1:8529'});
module.exports = {
    getAllUsers : function()
    {
        return db.database('superrango')
                 .then(function (mydb) {return mydb.query('FOR x IN Users RETURN x');})
                 .then(function (cursor) { return  cursor.all();});
    }
}

Finally cracked it

var arangojs = require("arangojs");
var db = new arangojs.Database('http://127.0.0.1:8529');
db.useDatabase("superrango");
db.useBasicAuth("root", "asdf");

module.exports = {
    getAllUsers : function()
    {
                 return db.query('FOR x IN Users RETURN x')
                         .then((value) => {return value.all();});

    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM