1

Curent Query:

db.getCollection("users").find({"_id" : ObjectId("606d72765bbe16d6be2f50d1")}, {"interests" :1 , "_id" :0})

Current Output:

{
    "interests" : [
        "Beaches",
        "Mountains",
        "Temples",
        "Nightlifes",
        "Shopping"
    ]
}

Expected output:

[
        "Beaches",
        "Mountains",
        "Temples",
        "Nightlifes",
        "Shopping"
]

How to get this expected output? Can anyone help. Thanks in advance.

2 Answers 2

1
var data = db.getCollection("users").find({"_id" : ObjectId("606d72765bbe16d6be2f50d1")}, {"interests" :1 , "_id" :0})



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

1 Comment

var data = { "interests" : [ "Beaches", "Mountains", "Temples", "Nightlifes", "Shopping" ] } console.log(data.interests)
0

Try this:

var data = db.getCollection("users").find({"_id" : ObjectId("606d72765bbe16d6be2f50d1")}, {"interests" :1 , "_id" :0}).toArray()

console.log('Data: ', data[0].interests);

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.