0

For example, the mongo document as follows:

{
    "_id": ObjectId("xxx"),
    "array": [
        0,
        1,
        [2, 3],
        4
    ]
}

Is there a method to get the 2 from the document?

6
  • I imagine the solution would be very close to the solution here stackoverflow.com/questions/13452745/… Commented Oct 31, 2016 at 6:01
  • 1
    By get the 2 you mean "find the documents that has a 2 there" or "select only the 2 from the document in the query"? What is the context that you need it? is it a batch? how many data? there might be simple solutions but they are not so fast. Commented Oct 31, 2016 at 6:10
  • @AmiramKorach It means select only 3 from the document. There are 3000+ records. Commented Oct 31, 2016 at 9:18
  • Where are you trying to do it? node? mongo shell? Commented Oct 31, 2016 at 10:02
  • @AmiramKorach python with pymongo Commented Nov 1, 2016 at 2:10

0

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.