I have a mongo collection as follows:
{
"id": "510aec8e8426e96c156a0946",
"name": "ABC",
"categoryToShardMap": null
},
{
"id": "510aecd284268e0f60e547a5",
"name": "XYZ",
"categoryToShardMap": {
"shoes": 1
},
{
"id": "510aecbd84268e0f60e547a4",
"name": "AAA",
"categoryToShardMap": {
"shoes": 3,
"jeans": 2
}
Where I have declared field 'categoryToShardMap' as :
private HashMap<String, Long> categoryToShardMap;
I am trying to create a REST Api where if someone provides the shardId, he should get back the mongo document which contains it. For example: if I pass shardId = 3, I should receive the mongo document:
{
"id": "510aecbd84268e0f60e547a4",
"name": "AAA",
"categoryToShardMap": {
"shoes": 3,
"jeans": 2
}
I am trying to use java to do this. But I am not sure how should I query this using mongotemplate or DBObject. Can someone point to me to some examples on how to query if a map stored in mongo document contains a specified value?