135-1821-9792

Mongodb基础实践(二)-创新互联

 在前面的文章里面主要介绍了MongoDB的文档,集合,数据库等操作和对文档的增、删、改相关知识,接下来会总结一点有关查询的相关知识。

创新互联专注于德惠网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供德惠营销型网站建设,德惠网站制作、德惠网页设计、德惠网站官网定制、小程序制作服务,打造德惠网络公司原创品牌,更为您提供德惠网站排名全网营销落地服务。

 在MySQL中,我们知道数据查询是优化的主要内容,读写分离等技术都是可以用来处理数据库查询优化的,足以见数据库查询是每个系统中很重要的一部分,之前介绍了find的简单使用,下面会介绍一些相对比较复杂一点的查询。

一、数据查询

 MySQL数据库中主要是用select 结合where子句实现数据的查询,功能特别强大,例如多表联合查询、支持正则表达式等。不在这里做过多的相关介绍。这里主要介绍MongoDB的相关查询,MongoDB中主要用find()实现数据的查询,同时也可以使用一些条件限制。

1.1显示单条数据

 在上篇文章中提到了find()的使用,但是每次查询数据,都是查询所有的,显示其中的一部分,可以用it迭代。有时候我们想要查询其中的一条数据,具体操作要根据具体需求实现。

MongoDB 查询数据的语法

db.collection.find(query, projection)

   query :可选,使用查询操作符指定查询条件
   projection :可选,使用投影操作符指定返回的键。查询时返回文档中所有键值, 只需省略该参数即可(默认省略)。可以使用 pretty() 方法以易读的方式来读取数据,,语法格式如下

>db.col.find().pretty()

pretty() 方法以格式化的方式来显示所有文档。

例如:

db.winner.find().pretty() { "_id" : ObjectId("592e7d1caaa464fa8a557e95"), "winne" : 1955 } { "_id" : ObjectId("592e7d1eaaa464fa8a557e96"), "winne" : 1955 } { "_id" : ObjectId("592e7d1faaa464fa8a557e97"), "winne" : 1955 } { "_id" : ObjectId("592e7d1faaa464fa8a557e98"), "winne" : 1955 } { "_id" : ObjectId("592e7d21aaa464fa8a557e99"), "winne" : 1955 } { "_id" : ObjectId("592e7d22aaa464fa8a557e9a"), "winne" : 1955 } { "_id" : ObjectId("592e7e14aaa464fa8a557ec4"), "winne" : 41 } { "_id" : ObjectId("592e7e14aaa464fa8a557ec5"), "winne" : 42 } { "_id" : ObjectId("592e7e14aaa464fa8a557ec6"), "winne" : 43 } { "_id" : ObjectId("592e7e14aaa464fa8a557ec7"), "winne" : 44 }

1、查询某个集合中的所有数据

db.winner.find() { "_id" : ObjectId("592e7d1caaa464fa8a557e95"), "winne" : 1955 } { "_id" : ObjectId("592e7d1eaaa464fa8a557e96"), "winne" : 1955 } { "_id" : ObjectId("592e7d1faaa464fa8a557e97"), "winne" : 1955 } { "_id" : ObjectId("592e7d1faaa464fa8a557e98"), "winne" : 1955 } { "_id" : ObjectId("592e7d21aaa464fa8a557e99"), "winne" : 1955 } { "_id" : ObjectId("592e7d22aaa464fa8a557e9a"), "winne" : 1955 } { "_id" : ObjectId("592e7e14aaa464fa8a557ec4"), "winne" : 41 } { "_id" : ObjectId("592e7e14aaa464fa8a557ec5"), "winne" : 42 } { "_id" : ObjectId("592e7e14aaa464fa8a557ec6"), "winne" : 43 } { "_id" : ObjectId("592e7e14aaa464fa8a557ec7"), "winne" : 44 } { "_id" : ObjectId("592e7e14aaa464fa8a557ec8"), "winne" : 45 } { "_id" : ObjectId("592e7e14aaa464fa8a557ec9"), "winne" : 46 } { "_id" : ObjectId("592e7e14aaa464fa8a557eca"), "winne" : 47 } { "_id" : ObjectId("592e7e14aaa464fa8a557ecb"), "winne" : 48 } { "_id" : ObjectId("592e7e14aaa464fa8a557ecc"), "winne" : 49 } { "_id" : ObjectId("592e7e14aaa464fa8a557ecd"), "winne" : 50 } { "_id" : ObjectId("592e7e14aaa464fa8a557ece"), "winne" : 51 } { "_id" : ObjectId("592e7e14aaa464fa8a557ecf"), "winne" : 52 } { "_id" : ObjectId("592e7e14aaa464fa8a557ed0"), "winne" : 53 } { "_id" : ObjectId("592e7e14aaa464fa8a557ed1"), "winne" : 54 } Type "it" for more

默认显示20条数据,其他数据可以输入it迭代。

2、显示一条数据

 find()是输出所有结果,里面可能有些文档内容相同,但是“_id”肯定是不一样的,这时我们可以使用findOne()方法查询,或者可以使用db.winner.find({winne:1955}).limit(1)。

db.winner.find({winne:1955}) { "_id" : ObjectId("592e7d1caaa464fa8a557e95"), "winne" : 1955 } { "_id" : ObjectId("592e7d1eaaa464fa8a557e96"), "winne" : 1955 } { "_id" : ObjectId("592e7d1faaa464fa8a557e97"), "winne" : 1955 } { "_id" : ObjectId("592e7d1faaa464fa8a557e98"), "winne" : 1955 } { "_id" : ObjectId("592e7d21aaa464fa8a557e99"), "winne" : 1955 } { "_id" : ObjectId("592e7d22aaa464fa8a557e9a"), "winne" : 1955 } 假如要查询winner集合中winne=1955的一条数据,而用find()查询出所有的数据,这时就可以使用findOne() db.winner.findOne({winne:1955}) { "_id" : ObjectId("592e7d1caaa464fa8a557e95"), "winne" : 1955 } 或者可以使用 db.winner.find({winne:1955}).limit(1) { "_id" : ObjectId("592e7d1caaa464fa8a557e95"), "winne" : 1955 } 两者的区别 findOne()有点类似MySQL里面的distinct,会返回查询的第一条结果,如果搜索不到想要的数据就会 返回NULL, db.winner.findOne({winne:200888}) null db.winner.find({winne:1955}).limit(1)方法就和MySQL里面的limit是一样的,主要是限制查询结果的条数。

3、查询满足一定条件的数据

 在MySQL中查询时,可以结合where以及字段等信息查询数据,而MongoDB中也是可以的,同样可以支持一些条件判断语句。


格式范例RDBMS中的类似语句
等于{:}db.col.find({"winne":"1995"}).pretty()where winne = '50'
小于{:{$lt:}}db.col.find({"winne":{$lt:50}}).pretty()where winne < 50
小于或等于{:{$lte:}}db.col.find({"winne":{$lte:50}}).pretty()where winne <= 50
大于{:{$gt:}}db.col.find({"winne":{$gt:50}}).pretty()where winne > 50
大于或等于{:{$gte:}}db.col.find({"winne":{$gte:50}}).pretty()where winne >= 50
不等于{:{$ne:}}db.col.find({"winne":{$ne:50}}).pretty()where winne != 50
$gt -------- greater than   $gte --------- gt equal $lt -------- less than      $lte --------- lt equal $ne ----------- not equal 1、查询winner集合中winne<50的相关数据  db.winner.find({winne:{$lt :50}}) { "_id" : ObjectId("592e7e14aaa464fa8a557ec4"), "winne" : 41 } { "_id" : ObjectId("592e7e14aaa464fa8a557ec5"), "winne" : 42 } { "_id" : ObjectId("592e7e14aaa464fa8a557ec6"), "winne" : 43 } { "_id" : ObjectId("592e7e14aaa464fa8a557ec7"), "winne" : 44 } { "_id" : ObjectId("592e7e14aaa464fa8a557ec8"), "winne" : 45 } { "_id" : ObjectId("592e7e14aaa464fa8a557ec9"), "winne" : 46 } { "_id" : ObjectId("592e7e14aaa464fa8a557eca"), "winne" : 47 } { "_id" : ObjectId("592e7e14aaa464fa8a557ecb"), "winne" : 48 } { "_id" : ObjectId("592e7e14aaa464fa8a557ecc"), "winne" : 49 } { "_id" : ObjectId("592e7e17aaa464fa8a557f28"), "winne" : 41 } { "_id" : ObjectId("592e7e17aaa464fa8a557f29"), "winne" : 42 } { "_id" : ObjectId("592e7e17aaa464fa8a557f2a"), "winne" : 43 } { "_id" : ObjectId("592e7e17aaa464fa8a557f2b"), "winne" : 44 } 2、查询winner集合中40=

4、MongoDB AND 条件

MongoDB 的 find() 方法可以传入多个键(key),每个键(key)以逗号隔开,语法格式如下:

>db.winner.find({key1:value1, key2:value2}).pretty()

#插入测试数据 for(i=0;i<20;i++)db.info2.insert({name:"linux", object:"SA", company:"docker", phone:i}) for(i=0;i<20;i++)db.info2.insert({name:"openstack", object:"DBA", company:"could", phone:i}) #检查测试数据 > db.info2.find() db.info2.find() { "_id" : ObjectId("592f838dd276944818f7edb4"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 0 } { "_id" : ObjectId("592f838dd276944818f7edb5"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 1 } { "_id" : ObjectId("592f838dd276944818f7edb6"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 2 } { "_id" : ObjectId("592f838dd276944818f7edb7"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 3 } { "_id" : ObjectId("592f838dd276944818f7edb8"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 4 } { "_id" : ObjectId("592f838dd276944818f7edb9"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 5 } { "_id" : ObjectId("592f838dd276944818f7edba"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 6 } { "_id" : ObjectId("592f838dd276944818f7edbb"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 7 } { "_id" : ObjectId("592f838dd276944818f7edbc"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 8 } { "_id" : ObjectId("592f838dd276944818f7edbd"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 9 } { "_id" : ObjectId("592f838dd276944818f7edbe"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 10 } { "_id" : ObjectId("592f838dd276944818f7edbf"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 11 } { "_id" : ObjectId("592f838dd276944818f7edc0"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 12 } { "_id" : ObjectId("592f838dd276944818f7edc1"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 13 } { "_id" : ObjectId("592f838dd276944818f7edc2"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 14 } { "_id" : ObjectId("592f838dd276944818f7edc3"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 15 } { "_id" : ObjectId("592f838dd276944818f7edc4"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 16 } { "_id" : ObjectId("592f838dd276944818f7edc5"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 17 } { "_id" : ObjectId("592f838dd276944818f7edc6"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 18 } { "_id" : ObjectId("592f838dd276944818f7edc7"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 19 } >db.info2.find().count()  #检查数据的条数 40 #筛选name=linux object=SA phone<5 db.info2.find({name:"linux",object:"SA",phone:{$lt:5}})  执行  db.info2.find({name:"linux",object:"SA",phone:{$lt:5}}) { "_id" : ObjectId("592f838dd276944818f7edb4"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 0 } { "_id" : ObjectId("592f838dd276944818f7edb5"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 1 } { "_id" : ObjectId("592f838dd276944818f7edb6"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 2 } { "_id" : ObjectId("592f838dd276944818f7edb7"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 3 } { "_id" : ObjectId("592f838dd276944818f7edb8"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 4 } 筛选name=linux object=SA   5

5 MongoDB OR 条件
MongoDB 除了有类似MySQL的AND条件语句外,还有OR 条件语句,OR 条件语句使用了关键字 $or,语法格式如下:
>db.collections.find(
  {
     $or: [
       {key1: value1}, {key2:value2}
     ]
  }
).pretty()

#查name=linux 或者object=redis db.info2.find( {$or:[{name:"linux"},{object:"redis"}] } ) db.info2.find(db.info2.find( ... {$or:[{name:"linux"},{object:"redis"}]{$or:[{name:"linux"},{object:"redis"}] ...  ... }} ... )) { "_id" : ObjectId("592f838dd276944818f7edb4"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 0 } { "_id" : ObjectId("592f838dd276944818f7edb5"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 1 } { "_id" : ObjectId("592f838dd276944818f7edb6"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 2 } { "_id" : ObjectId("592f838dd276944818f7edb7"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 3 } { "_id" : ObjectId("592f838dd276944818f7edb8"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 4 } { "_id" : ObjectId("592f838dd276944818f7edb9"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 5 } { "_id" : ObjectId("592f838dd276944818f7edba"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 6 } { "_id" : ObjectId("592f838dd276944818f7edbb"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 7 } { "_id" : ObjectId("592f838dd276944818f7edbc"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 8 } { "_id" : ObjectId("592f838dd276944818f7edbd"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 9 } { "_id" : ObjectId("592f838dd276944818f7edbe"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 10 } { "_id" : ObjectId("592f838dd276944818f7edbf"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 11 } { "_id" : ObjectId("592f838dd276944818f7edc0"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 12 } { "_id" : ObjectId("592f838dd276944818f7edc1"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 13 } { "_id" : ObjectId("592f838dd276944818f7edc2"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 14 } { "_id" : ObjectId("592f838dd276944818f7edc3"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 15 } { "_id" : ObjectId("592f838dd276944818f7edc4"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 16 } { "_id" : ObjectId("592f838dd276944818f7edc5"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 17 } { "_id" : ObjectId("592f838dd276944818f7edc6"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 18 } { "_id" : ObjectId("592f838dd276944818f7edc7"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 19 } Type "it" for more > itit { "_id" : ObjectId("592f8964d276944818f7eddc"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 0 } { "_id" : ObjectId("592f8964d276944818f7eddd"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 1 } { "_id" : ObjectId("592f8964d276944818f7edde"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 2 } { "_id" : ObjectId("592f8964d276944818f7eddf"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 3 } { "_id" : ObjectId("592f8964d276944818f7ede0"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 4 } { "_id" : ObjectId("592f8964d276944818f7ede1"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 5 } { "_id" : ObjectId("592f8964d276944818f7ede2"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 6 } { "_id" : ObjectId("592f8964d276944818f7ede3"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 7 } { "_id" : ObjectId("592f8964d276944818f7ede4"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 8 } { "_id" : ObjectId("592f8964d276944818f7ede5"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 9 }

6、AND和OR综合使用

查询phone<5,name=MongoDB或者name=linux

db.info2.find({phone:{$lt:5},$or:[{name:"MongoDB"},{name:"linux"}]}) db.info2.find({phone:{$lt:5},$or:[{name:"MongoDB"},{name:"linux"}]}) { "_id" : ObjectId("592f838dd276944818f7edb4"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 0 } { "_id" : ObjectId("592f838dd276944818f7edb5"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 1 } { "_id" : ObjectId("592f838dd276944818f7edb6"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 2 } { "_id" : ObjectId("592f838dd276944818f7edb7"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 3 } { "_id" : ObjectId("592f838dd276944818f7edb8"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 4 } { "_id" : ObjectId("592f8964d276944818f7eddc"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 0 } { "_id" : ObjectId("592f8964d276944818f7eddd"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 1 } { "_id" : ObjectId("592f8964d276944818f7edde"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 2 } { "_id" : ObjectId("592f8964d276944818f7eddf"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 3 } { "_id" : ObjectId("592f8964d276944818f7ede0"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 4 }

7、查询结果排序

在MySQL中是有order by条件,可以根据desc或者asc进行升序或者降序操作,而MongoDB中是可以利用sort()方法实现排序的,例如对6中的结果处理,根据phone排序。

基本语法

db.info2.find().sort({phone:1}) #这里phone表示根据该key排序,1表示升序,-1表示降序

db.info2.find({phone:{$lt:5},$or:[{name:"MongoDB"},{name:"linux"}]}).sort({phone:1}) { "_id" : ObjectId("592f838dd276944818f7edb4"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 0 } { "_id" : ObjectId("592f8964d276944818f7eddc"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 0 } { "_id" : ObjectId("592f838dd276944818f7edb5"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 1 } { "_id" : ObjectId("592f8964d276944818f7eddd"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 1 } { "_id" : ObjectId("592f838dd276944818f7edb6"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 2 } { "_id" : ObjectId("592f8964d276944818f7edde"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 2 } { "_id" : ObjectId("592f838dd276944818f7edb7"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 3 } { "_id" : ObjectId("592f8964d276944818f7eddf"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 3 } { "_id" : ObjectId("592f838dd276944818f7edb8"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 4 } { "_id" : ObjectId("592f8964d276944818f7ede0"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 4 }

8、MongoDB Skip() 方法

在前面介绍了limit(),sort(),count()等方法,接下来要介绍一个比较有趣的skip()方法,在使用limit()的时候可以显示你要求的几条,而skip()方法是跳过几条。

db.info2.find({phone:{$lt:5},$or:[{name:"MongoDB"},{name:"linux"}]}).sort({phone:1}) { "_id" : ObjectId("592f838dd276944818f7edb4"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 0 } { "_id" : ObjectId("592f8964d276944818f7eddc"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 0 } { "_id" : ObjectId("592f838dd276944818f7edb5"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 1 } { "_id" : ObjectId("592f8964d276944818f7eddd"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 1 } { "_id" : ObjectId("592f838dd276944818f7edb6"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 2 } { "_id" : ObjectId("592f8964d276944818f7edde"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 2 } { "_id" : ObjectId("592f838dd276944818f7edb7"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 3 } { "_id" : ObjectId("592f8964d276944818f7eddf"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 3 } { "_id" : ObjectId("592f838dd276944818f7edb8"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 4 } { "_id" : ObjectId("592f8964d276944818f7ede0"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 4 } 使用skip()方法 db.info2.find({phone:{$lt:5},$or:[{name:"MongoDB"},{name:"linux"}]}).sort({phone:1}).skip(3) { "_id" : ObjectId("592f8964d276944818f7eddd"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 1 } { "_id" : ObjectId("592f838dd276944818f7edb6"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 2 } { "_id" : ObjectId("592f8964d276944818f7edde"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 2 } { "_id" : ObjectId("592f838dd276944818f7edb7"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 3 } { "_id" : ObjectId("592f8964d276944818f7eddf"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 3 } { "_id" : ObjectId("592f838dd276944818f7edb8"), "name" : "linux", "object" : "SA", "company" : "docker", "phone" : 4 } { "_id" : ObjectId("592f8964d276944818f7ede0"), "name" : "MongoDB", "object" : "redis", "company" : "winner", "phone" : 4 } skip 方法有点类似于MySQL里面的limit之间间隔情况。

这里介绍了有关查询的问题,在数据库中,查询是非常重要的一部分,所以介绍的篇幅也是比较多的,后期遇到其他问题也会继续总结输出。

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网页题目:Mongodb基础实践(二)-创新互联
文章转载:http://kswsj.com/article/dsdepd.html

其他资讯



Copyright © 2009-2022 www.kswsj.com 成都快上网科技有限公司 版权所有 蜀ICP备19037934号