pouchdb-find

pouchdb-find

环境搭建

下载lib

	bower install pouchdb-find

引入js

	<script src="pouchdb.js"></script>
<script src="pouchdb.find.js"></script>

使用

1.createIndex

	db.createIndex({
index: {
fields: ['foo']
}
}).then(function (result) {
// yo, a result
}).catch(function (err) {
// ouch, an error
});

2.find

	db.find({
selector: {name: 'Mario'},
fields: ['_id', 'name'],
sort: ['name']
}).then(function (result) {
// yo, a result
}).catch(function (err) {
// ouch, an error
});

demo

	db.createIndex({
index: {fields: ['name']}
}).then(function () {
return db.find({
selector: {name: {$gt: null}},
sort: ['name']
});
});

example Result

	{
"docs": [
{
"_id": "mario",
"name": "Mario"
}
]
}

find 查询语法

为了避免出现bug 在每个查询都添加_id: {$gte: null} (可以设为null意外的值)

	db.find({
selector: {
_id: {$gte: null},
name: {$eq: 'Mario'}
}
});

条件关键词解析

  • $lt Match fields "less than" this one.
  • $gt Match fields "greater than" this one.
  • $lte Match fields "less than or equal to" this one.
  • $gte Match fields "greater than or equal to" this one.
  • $eq Match fields equal to this one.
  • $ne Match fields not equal to this one.
  • $exists True if the field should exist, false otherwise.
  • $type One of: "null", "boolean", "number", "string", "array", or "object".
  • $regex use RegExp

相等查询

	//1.
db.find({
selector: {
_id: {$gte: null},
name: {$eq: 'Mario'}
}
}); //2.
db.find({
selector: {
_id: {$gte: null},
name: 'Mario'
}
});

多条件查询

	//1.
db.find({
selector: {
_id: {$gte: null},
series: 'Mario',
debut: { $gt: 1990 }
}
}); //2.
db.find({
selector: {
$and: [
_id: {$gte: null},
{ series: 'Mario' },
{ debut: { $gt: 1990 } }
]
}
});

模糊查询$regex

	var keyword = 'mik'
var regExp = new RegExp('.*' + keyword + '.*', 'i');
db.find({
selector:{
_id: {"$gte": "NOB", "$lte": 'NOE'},
name:{"$regex": regExp}
}
})
.then(function(result){
//do some thing
var results = result.docs; })

pouchdb-find( pouchdb查询扩展插件 ,便于查询)的更多相关文章

  1. SubSonic3.0插件分页查询速度测试

    使用SubSonic3.0一段时间了,一直都想找机会测试一下各种查询分页速度,对比一下插件的查询效率到底怎么样,所以昨天写好了测试程序,准备好1K.1W.10W.50W和100W记录的数据表,早上详细 ...

  2. Dapper 链式查询 扩展

    Dapper 链式查询扩展 DapperSqlMaker   Github地址:https://github.com/mumumutou/DapperSqlMaker  欢迎大佬加入 Demo: 查询 ...

  3. sql的行转列(PIVOT)与列转行(UNPIVOT) webapi 跨域问题 Dapper 链式查询 扩展 T4 代码生成 Demo (抽奖程序)

    sql的行转列(PIVOT)与列转行(UNPIVOT)   在做数据统计的时候,行转列,列转行是经常碰到的问题.case when方式太麻烦了,而且可扩展性不强,可以使用 PIVOT,UNPIVOT比 ...

  4. MySQL -- 全文检索(查询扩展检索)

    通常用在查询的关键词太短,用户需要隐含知识进行扩展.例如,查单词database时,用户可能还希望不仅仅包含database的文档,可能还指包含mysql.oracle.db2等单词.这时就需要查询扩 ...

  5. 【spring boot】14.spring boot集成mybatis,注解方式OR映射文件方式AND pagehelper分页插件【Mybatis】pagehelper分页插件分页查询无效解决方法

    spring boot集成mybatis,集成使用mybatis拖沓了好久,今天终于可以补起来了. 本篇源码中,同时使用了Spring data JPA 和 Mybatis两种方式. 在使用的过程中一 ...

  6. Queryable查询扩展

    /// <summary> /// 查询扩展 /// </summary> /// <typeparam name="T"></typep ...

  7. 16.AutoMapper 之可查询扩展(Queryable Extensions)

    https://www.jianshu.com/p/4b23e94a7825 可查询扩展(Queryable Extensions) 当在像NHibernate或者Entity Framework之类 ...

  8. Elasticsearch使用系列-基本查询和聚合查询+sql插件

    Elasticsearch使用系列-ES简介和环境搭建 Elasticsearch使用系列-ES增删查改基本操作+ik分词 Elasticsearch使用系列-基本查询和聚合查询+sql插件 Elas ...

  9. django----对model查询扩展

    基于对象关联查询 一对多查询(Book--Publish): 正向查询,按字段: (从关联的表中查询) book_obj.publish : 与这本书关联的出版社对象 book_obj.publish ...

随机推荐

  1. EntityFramework6.X之DataAnnotations

    DataAnnotations 在web开发中不仅在客户端需要执行验证逻辑,会对会对用户向表单中输入的数据给出一个即时反馈:且在服务器端也需验证逻辑,因为来自网络的信息都是不能信任的.在MVC中通常是 ...

  2. Vulkan Tutorial 02 编写Vulkan应用程序框架原型

    操作系统:Windows8.1 显卡:Nivida GTX965M 开发工具:Visual Studio 2017 General structure 在上一节中,我们创建了一个正确配置.可运行的的V ...

  3. webpack 初识

    Webpack介绍 webpack 官网 http://webpack.github.io/docs/ webpack 中文地址:https://doc.webpack-china.org/ webp ...

  4. Java中的会话管理——HttpServlet,Cookies,URL Rewriting(译)

    参考谷歌翻译,关键字直接使用英文,原文地址:http://www.journaldev.com/1907/java-session-management-servlet-httpsession-url ...

  5. FTP主动模式和被动模式的区别

    基础知识: FTP只通过TCP连接,没有用于FTP的UDP组件.FTP不同于其他服务的是它使用了两个端口, 一个数据端口和一个命令端口(或称为控制端口).通常21端口是命令端口,20端口是数据端口.当 ...

  6. Node.js安装和配置

    今天有时间开始要研究Node.js了,项目的需要,先把环境正好,初次接触,把安装和配置过程记录下来,以备不时之需.言归正传. 1.打开NodeJS的官网,下载和自己系统相配的NodeJS的安装程序,包 ...

  7. File字节流

    1.    File f = new File("文件路径")      注意:相对路径:非web项目的相对都是以项目为起点.(src/a/txt(建议)      绝对路径:f: ...

  8. Eclipse中如何显示代码行

    方法一 快捷键方式: 按住 Ctrl + F10 选择 show  Line Numbers 方法二 手动操作: Window -- Prefences -- General -- Editors - ...

  9. JS学习笔记——JavaScript继承的6种方法(原型链、借用构造函数、组合、原型式、寄生式、寄生组合式)

    JavaScript继承的6种方法 1,原型链继承 2,借用构造函数继承 3,组合继承(原型+借用构造) 4,原型式继承 5,寄生式继承 6,寄生组合式继承 1.原型链继承. <script t ...

  10. Android之使用JAVA占位符格式数据(很实用)

    小编虽然是学java出生,但工作之后就一直从事android开发,很多java基础都忘记完了,最近一年从ES换到了AS,原来的很多习惯都收到了挑战,比如我喜欢ES写方法的时候先在JAVA projec ...