MongoDB Query in Java, search/find in nested object

前端 未结 4 1879
猫巷女王i
猫巷女王i 2021-01-19 13:16

I\'m having a little trouble with a query in Java on a MongoDB.

I have the follow structure in the database:

            {
              \"_id\" : Ob         


        
4条回答
  •  别那么骄傲
    2021-01-19 13:41

    MongoDB uses a 'match object' as a query. So to find objects that have status.name equal to "Expired", you could feed an object like such:

    { "status.name": "Expired" }

    From Java you'll need to create a DBOjbect like the above to use as the match (returning everything that ... matches with the match object) and send that to the database as a query. Assuming you'll have a connection to MongoDB from Java, use the find-method to execute the query you're after.

提交回复
热议问题