i want to access the embedded document through java query from mongodb.from a simple document its easy but how can we access from embedded document ?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- MongoDB can not create unique sparse index (duplic
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
If I understand you correctly, you can find the answer of your question below.
Say you have the following nested document.
If you mean to make query on the nested documents then you can access the embedded object using the following java code.
If you mean to extract embedded document from the document then you can use Map/Reduce or Aggregation framework.
Ian Daniel is still added the code to insert nested documents that you asked. You can also visit this page to see some detailed examples.
The following Java code will insert a document of the form
{ID:23 {Name:{"FirstName": "Ahmad", "SecondName":"Khan"}}