1

I was trying to solve a query given in an assessment to fetch details from a collection. The assessment was in online editor so I had to follow the base query structure. MONGODB version 4.4

The base query was looking like below.

{
find : "MY_COLLECTION_1"
}

The collection name is "MY_COLLECTION_1", and there is field "FirstName" column in the collections like below.

{

{

"FirstName": "ABC"
}
{

"FirstName": "XYZ"
}
}

I have never seen the below format to fetch the data. Need help with this.

{
find : "MY_COLLECTION_1"
}

I tried to fetch something like below.

{
"find" : "MY_COLLECTION_1",
"FirstName" : "ABC"
}

but it's saying invalid BSON format

1 Answer 1

1

The "online editor" appears to be using the find database command, which has the basic structure:

{
      find: <string>,
      filter: <document>,
      sort: <document>,
      projection: <document>,
      hint: <document or string>
}

You will likely need to use the filter field to pass in a query.

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.