84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
{"_id":"37389873","Date":{"name":{"count":"7","user": "liyang",}
}
比如数据库中存的这个文档,我想取count中的值7,只取数字7,不要文档,改怎么实现呢??
Finally, I used Jackson to convert the json string into a map, and then used map to slice it layer by layer, and finally returned a numerical value
db.xxx.findOne({"_id":"37389873"}, {"Date.name.count": 1}).Date.name.count
Operation effect
~/tmp ▶ cat mmm.js #!/usr/bin/env mongo var db = connect('test'); db.xxx.drop(); db.xxx.insert({ "_id": "37389873", "Date":{ "name":{"count":"7", "user": "liyang", } } }); print( db.xxx.findOne({"_id":"37389873"}, {"Date.name.count": 1}).Date.name.count ); ~/tmp ▶ ./mmm.js MongoDB shell version: 2.6.3 connecting to: test connecting to: test 7
http://jongo.org/Maybe this is what you are looking for
spring’s mongodb plug-in can satisfy
BasicQuery query = new BasicQuery(query,fields);
query is the query conditionfields is the field to be queried
collections.find(docQuery).projection(keys)
Finally, I used Jackson to convert the json string into a map, and then used map to slice it layer by layer, and finally returned a numerical value
db.xxx.findOne({"_id":"37389873"}, {"Date.name.count": 1}).Date.name.count
Operation effect
http://jongo.org/
Maybe this is what you are looking for
spring’s mongodb plug-in can satisfy
query is the query condition
fields is the field to be queried
collections.find(docQuery).projection(keys)