Mongo DB request in Java Spring-data Mongo

后端 未结 1 789
自闭症患者
自闭症患者 2021-01-25 18:27

I have an array inside of document.

{
    \"id\" : \"id_1\",
    \"name\" : \"name_1\";
    \"additionalData\" : [
        {
             \"additionalDataId\" :          


        
1条回答
  •  旧巷少年郎
    2021-01-25 19:12

    If I understood the question correctly, this will give the desired results.

    Query query = new Query(new Criteria().andOperator(
        Criteria.where("name").is("name_1"),
        Criteria.where("additionalData.additionalDataName").is("name_1_2")
    ));
    query.fields().include("additionalData").exclude("_id");
    
    List results = template.find(query, collectionName, org.bson.Document.class);
    

    0 讨论(0)
提交回复
热议问题