1

Имеется вот такой документ, как мне получить все entityIds из массива indicators. Да, можно получить весь объект и вытащить, но хотелось бы узнать как одним запросом получить список из строк

{
    "_id": {
        "$oid": "5e798999c0f57a56f7fdeef9"
    },
    "_class": "IndicatorPanel",
    "name": "Новая панель индикаторов",
    "description": "",
    "rowCount": {
        "$numberInt": "3"
    },
    "colCount": {
        "$numberInt": "3"
    },
    "indicatorGroupId": "5e798997c0f57a56f7fdeef8",
    "projectId": "5e79894ac0f57a56f7fdeed2",
    "indicators": [
        [
            {
                "_id": null,
                "name": "",
                "description": "",
                "passwordNeeded": false,
                "rowNo": {
                    "$numberInt": "0"
                },
                "colNo": {
                    "$numberInt": "0"
                },
                "entityType": "DEVICE",
                "entityIds": [
                    "5e798991c0f57a56f7fdeef3"
                ],
                "filterTags": {
                    "tags": []
                }
            },
            {
                "_id": null,
                "name": "",
                "description": "",
                "passwordNeeded": false,
                "rowNo": {
                    "$numberInt": "0"
                },
                "colNo": {
                    "$numberInt": "1"
                },
                "entityType": "NONE",
                "entityIds": [],
                "filterTags": {
                    "tags": []
                }
            },
            {
                "_id": null,
                "name": "",
                "description": "",
                "passwordNeeded": false,
                "rowNo": {
                    "$numberInt": "0"
                },
                "colNo": {
                    "$numberInt": "2"
                },
                "entityType": "NONE",
                "entityIds": [],
                "filterTags": {
                    "tags": []
                }
            }
        ],
        [
            {
                "_id": null,
                "name": "",
                "description": "",
                "passwordNeeded": false,
                "rowNo": {
                    "$numberInt": "1"
                },
                "colNo": {
                    "$numberInt": "0"
                },
                "entityType": "DEVICE",
                "entityIds": [
                    "5e798991c0f57a56f7fdeef4",
                    "5e798991c0f57a56f7fdeef7"
                ],
                "filterTags": {
                    "tags": []
                }
            },
            {
                "_id": null,
                "name": "",
                "description": "",
                "passwordNeeded": false,
                "rowNo": {
                    "$numberInt": "1"
                },
                "colNo": {
                    "$numberInt": "1"
                },
                "entityType": "NONE",
                "entityIds": [],
                "filterTags": {
                    "tags": []
                }
            },
            {
                "_id": null,
                "name": "",
                "description": "",
                "passwordNeeded": false,
                "rowNo": {
                    "$numberInt": "1"
                },
                "colNo": {
                    "$numberInt": "2"
                },
                "entityType": "NONE",
                "entityIds": [],
                "filterTags": {
                    "tags": []
                }
            }
        ],
        [
            {
                "_id": null,
                "name": "",
                "description": "",
                "passwordNeeded": false,
                "rowNo": {
                    "$numberInt": "2"
                },
                "colNo": {
                    "$numberInt": "0"
                },
                "entityType": "NONE",
                "entityIds": [],
                "filterTags": {
                    "tags": []
                }
            },
            {
                "_id": null,
                "name": "",
                "description": "",
                "passwordNeeded": false,
                "rowNo": {
                    "$numberInt": "2"
                },
                "colNo": {
                    "$numberInt": "1"
                },
                "entityType": "NONE",
                "entityIds": [],
                "filterTags": {
                    "tags": []
                }
            },
            {
                "_id": null,
                "name": "",
                "description": "",
                "passwordNeeded": false,
                "rowNo": {
                    "$numberInt": "2"
                },
                "colNo": {
                    "$numberInt": "2"
                },
                "entityType": "NONE",
                "entityIds": [],
                "filterTags": {
                    "tags": []
                }
            }
        ]
    ],
    "filterTags": {
        "tags": []
    }
}

1 ответ 1

0

Решил проверять не наличие, а получать количество устройств.

@CountQuery("{ $and : [ { 'projectId' : '?0' }, {'indicators': {'$elemMatch': { $elemMatch' : { entityType : '?1', entityIds : {$in : ?2}}}}}]}")
int countByProjectIdAndEntityTypeAndIdIn(String projectId, EntityType entityType, List<String> ids);

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.