最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

MongoDB下的查询操作(与JavaAPI查询操作对应)

来源:懂视网 责编:小采 时间:2020-11-09 12:05:56
文档

MongoDB下的查询操作(与JavaAPI查询操作对应)

MongoDB下的查询操作(与JavaAPI查询操作对应):[root@localhost ~]# mongo MongoDB shell version: 1.8.1 connecting to: test gt; db test gt; show collections 相关阅读: MongoDB Linux下的安装和启动 MongoDB下的高级查询示例 MongoDB Java API for 插
推荐度:
导读MongoDB下的查询操作(与JavaAPI查询操作对应):[root@localhost ~]# mongo MongoDB shell version: 1.8.1 connecting to: test gt; db test gt; show collections 相关阅读: MongoDB Linux下的安装和启动 MongoDB下的高级查询示例 MongoDB Java API for 插

[root@localhost ~]# mongo MongoDB shell version: 1.8.1 connecting to: test gt; db test gt; show collections

相关阅读:

MongoDB Linux下的安装和启动

MongoDB下的高级查询示例

MongoDB Java API for 插入和单collection基本查询使用示例

MongoDB下的查询操作(与Java API查询操作对应)

[root@localhost ~]# mongo
MongoDB shell version: 1.8.1
connecting to: test
> db
test
> show collections
data_test
system.indexes
system.users
> db.system.users.find()
{ "_id" : ObjectId("4dd73c7d247cb75e4995757b"), "user" : "iwtxokhtd", "readOnly" : false, "pwd" : "c728e00401a72282a2919648723dbff7" }
> db.data_test.find()
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a30"), "userId" : "10010171", "userName" : "Bill Tu1", "gender" : "m1", "interests" : { "game" : "game1", "ball" : "ball1", "other" : "nothing1" } }
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a31"), "userId" : "10010172", "userName" : "Bill Tu2", "gender" : "m2", "interests" : { "game" : "game2", "ball" : "ball2", "other" : "nothing2" } }
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a32"), "userId" : "10010173", "userName" : "Bill Tu3", "gender" : "m3", "interests" : { "game" : "game3", "ball" : "ball3", "other" : "nothing3" } }
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a33"), "userId" : "10010174", "userName" : "Bill Tu4", "gender" : "m4", "interests" : { "game" : "game4", "ball" : "ball4", "other" : "nothing4" } }
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a34"), "userId" : "10010175", "userName" : "Bill Tu5", "gender" : "m5", "interests" : { "game" : "game5", "ball" : "ball5", "other" : "nothing5" } }
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a35"), "userId" : "10010176", "userName" : "Bill Tu6", "gender" : "m6", "interests" : { "game" : "game6", "ball" : "ball6", "other" : "nothing6" } }
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a36"), "userId" : "10010177", "userName" : "Bill Tu7", "gender" : "m7", "interests" : { "game" : "game7", "ball" : "ball7", "other" : "nothing7" } }
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a37"), "userId" : "10010178", "userName" : "Bill Tu8", "gender" : "m8", "interests" : { "game" : "game8", "ball" : "ball8", "other" : "nothing8" } }
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a38"), "userId" : "10010179", "userName" : "Bill Tu9", "gender" : "m9", "interests" : { "game" : "game9", "ball" : "ball9", "other" : "nothing9" } }
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a39"), "userId" : "100101710", "userName" : "Bill Tu10", "gender" : "m10", "interests" : { "game" : "game10", "ball" : "ball10", "other" : "nothing10" } }
> db.data_test.findOne()
{
"_id" : ObjectId("4dd747cb3a491e68a1a84a30"),
"userId" : "10010171",
"userName" : "Bill Tu1",
"gender" : "m1",
"interests" : {
"game" : "game1",
"ball" : "ball1",
"other" : "nothing1"
}
}
> db.data_test.find({"userId":"10010171"})
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a30"), "userId" : "10010171", "userName" : "Bill Tu1", "gender" : "m1", "interests" : { "game" : "game1", "ball" : "ball1", "other" : "nothing1" } }
> db.data_test.find({"userId":"10010171","userName":"Bill Tu1"})
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a30"), "userId" : "10010171", "userName" : "Bill Tu1", "gender" : "m1", "interests" : { "game" : "game1", "ball" : "ball1", "other" : "nothing1" } }
> db.data_test.find({"userId":{$in:["10010171","10010172"]}})
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a30"), "userId" : "10010171", "userName" : "Bill Tu1", "gender" : "m1", "interests" : { "game" : "game1", "ball" : "ball1", "other" : "nothing1" } }
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a31"), "userId" : "10010172", "userName" : "Bill Tu2", "gender" : "m2", "interests" : { "game" : "game2", "ball" : "ball2", "other" : "nothing2" } }
> db.data_test.find({"userId":/10010171.*/i})
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a30"), "userId" : "10010171", "userName" : "Bill Tu1", "gender" : "m1", "interests" : { "game" : "game1", "ball" : "ball1", "other" : "nothing1" } }
{ "_id" : ObjectId("4dd747cb3a491e68a1a84a39"), "userId" : "100101710", "userName" : "Bill Tu10", "gender" : "m10", "interests" : { "game" : "game10", "ball" : "ball10", "other" : "nothing10" } }
>

linux

文档

MongoDB下的查询操作(与JavaAPI查询操作对应)

MongoDB下的查询操作(与JavaAPI查询操作对应):[root@localhost ~]# mongo MongoDB shell version: 1.8.1 connecting to: test gt; db test gt; show collections 相关阅读: MongoDB Linux下的安装和启动 MongoDB下的高级查询示例 MongoDB Java API for 插
推荐度:
标签: 查询 下的 java
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top