6

I create a collection with 8 documents, i want to query my releasedTime , here is my structure:

enter image description here

I try this query first , i can get the object movie data

db.collection.find({}, {movie: 1})

I don't know what to do next. I try this query:

db.collection.find({}, {movie.film: 1})

I suppose i will get film object data but its not working.

If i want to get all of my documents releasedTime data, what is the correct query ?

Any help would be appreciated. Thanks in advance.

2
  • please add a sample document and the expected output Commented Mar 23, 2018 at 7:36
  • I get an answer now. Thanks for your reply. Commented Mar 23, 2018 at 7:46

1 Answer 1

10

Try to wrap your projection key within quotes

db.collection.find({}, {"movie.film": 1})

Here is my try on mongo console with sample data:

{ item: "journal", status: "A", size: { h: 14, w: 21, uom: "cm" }, instock: [ { warehouse: "A", qty: 5 } ] } Check out this screen shot for the corresponding commands

In your case the query would be :

db.collection.find({}, {"movie.film.releasedDate": 1})
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer, i add the quotes and its working.

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.