Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db.listUsers not rerturning an array of ArangoUser #782

Closed
fspegni opened this issue Jan 31, 2023 · 1 comment
Closed

db.listUsers not rerturning an array of ArangoUser #782

fspegni opened this issue Jan 31, 2023 · 1 comment
Assignees
Labels
Bug A code defect that needs to be fixed.

Comments

@fspegni
Copy link

fspegni commented Jan 31, 2023

Hi everyone,

I'm observing an odd behavior with the following script (using arangojs 7.7.0):

const { Database, aql } = require("arangojs");
const db = new Database("http://db:8529");
db.useBasicAuth("myusername", "mypassword");
db.useDatabase("MyDatabase");
const col = db.collection("MyCollection");
db.query(aql`FOR doc in ${col} RETURN doc`).then(async (cursor) => { console.log("Done"); }); // it works up to here

db.listUsers().then((usersData) => { 
	console.log("Users data", usersData); // this does not print an array of ArangoUser as I'd expect, but an object of type IncomingMessage ... 
});

const usersData = await db.listUsers(); 
console.log("Users data", usersData); // same as above ...

const userDBs = await db.listUserDatabases(); // this works OK, it prints the names of available databasess, as expected (array of strings ...)

The value of variables usersData in both examples above is the following:

Users data <ref *2> IncomingMessage {
  _readableState: ReadableState {
    objectMode: false,
    highWaterMark: 16384,
    buffer: BufferList { head: null, tail: null, length: 0 },
    length: 0,
    pipes: [],
    flowing: true,
    ended: true,
    endEmitted: true,
    reading: false,
    constructed: true,
    sync: true,
    needReadable: false,
    emittedReadable: false,
    readableListening: false,
    resumeScheduled: false,
    errorEmitted: false,
    emitClose: true,
    autoDestroy: true,
    destroyed: true,
    errored: null,
    closed: true,
    closeEmitted: true,
    defaultEncoding: 'utf8',
    awaitDrainWriters: null,
    multiAwaitDrain: false,
    readingMore: true,
    dataEmitted: true,
    decoder: null,
    encoding: null,
    [Symbol(kPaused)]: false
  },
...

Following this documentation I'd expect an array of ArangoUser objects, instead.

Am I doing something wrong? Note that if I call another method (e.g. listUserDatabases()) I get the expected result (an array of strings).

@fspegni
Copy link
Author

fspegni commented Jan 31, 2023

ok, doing some in-depth search in your code e.g. here and comparing with the listUserDatabases, I realize I could get what I want by doing the same:

db.request({ path:"/_api/user" }, (res) => console.log("Users", res.body.result))

Thus, It seems to me there is a small bug in the listUsers function, that should pass a callback (as the listUserDatabases does)

@pluma4345 pluma4345 self-assigned this Apr 26, 2023
@pluma4345 pluma4345 added the Bug A code defect that needs to be fixed. label Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A code defect that needs to be fixed.
Projects
None yet
Development

No branches or pull requests

2 participants