1

I have MongoJS query call:

db.users.find({username:"eleeist"},function(err, docs) {
    console.log(docs);
});

The docs variable looks like this in console output:

[ { _id: 4fee05662b17f88abbeb60b6,
    username: 'eleeist',
    password: 'test' } ]

I would like to display the password of the user eleeist.

I tried docs.password but get awful errors.

So how do I select values from the returned query result?

1 Answer 1

3

docs is an array of documents, so to get the password of the first one you'd use docs[0].password.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.