mongodb use where and custom function to query mongodb存储过程
function name regexObjSubObjKey
function code
function(proto,value) {
var match=false;
var reg = new RegExp('.*'+value);
print(JSON.stringify(this.obj));
print(this['arr_'+proto]);
for(var key in this.obj['arr_'+proto]){
print(key);
if(key!='count'&&key!='isgame'){
match = reg.test(key);
if(match){
return true;
}
}
}
return false;
}
query demo
精简
db.test.find({$where:"regexObjSubObjKey('qq','1234567')"})
标准
db.test.find({$and:[{arr_qq:{$exists:true}},{$where:"regexObjSubObjKey('qq','1234567')"}]})
数据内容
{
"_id": "7654321",
"arr_qq": {
"1234567": {
"count": 8
},
"abcdefg": {
"count": 8
},
"count": 16
}
}
mongodb use where and custom function to query mongodb存储过程的更多相关文章
- Spring Boot 整合 Elasticsearch,实现 function score query 权重分查询
摘要: 原创出处 www.bysocket.com 「泥瓦匠BYSocket 」欢迎转载,保留摘要,谢谢! 『 预见未来最好的方式就是亲手创造未来 – <史蒂夫·乔布斯传> 』 运行环境: ...
- SpringMVC MongoDB之“基本文档查询(Query、BasicQuery)”
一.简介 spring Data MongoDB提供了org.springframework.data.mongodb.core.MongoTemplate对MongoDB的CRUD的操作,上一篇我 ...
- ES翻译之Function Score Query
Function Score Query 原文链接 function_score允许你修改通过查询获取文档的分数,很有用处,score function是计算昂贵的,以及在过滤一系列文档上计算分数是高 ...
- 搭建高可用MongoDB集群(一):配置MongoDB
在大数据的时代,传统的关系型数据库要能更高的服务必须要解决高并发读写.海量数据高效存储.高可扩展性和高可用性这些难题.不过就是因为这些问题Nosql诞生了. NOSQL有这些优势: 大数据量,可以通过 ...
- MongoDB学习(2)—Node.js与MongoDB的基本连接示例
前提 已经安装了node.js和MongoDB,本文使用的node.js是v0.12.0,MongoDB是3.0.0. 初始化数据 启动MongoDB服务,在test数据库中插入一条实例数据: db. ...
- Mongodb的入门(1)window安装mongodb
mongodb: Mongodb,分布式文档存储数据库,由C++语言编写,旨在为WEB应用提供可扩展的高性能数据存储解决方案.MongoDB是一个高性能,开源,无模式的文档型数据库,是当前NoSql数 ...
- springboot整合mongodb问题1-Decimal128和BigDecimal的转换之mongodb转换器使用(转)
转自:https://blog.csdn.net/weixin_41792559/article/details/79575524 1.Decimal128的了解由于mongodb4.3以上新加了De ...
- MongoDB学习(五)Linux环境安装MongoDB
一. 下载 从http://www.mongodb.org/downloads地址中下载:mongodb-linux-x86_64-2.4.11.tar 二. 安装 1>设置mongoDB ...
- MongoDB学习(二)Windows环境安装MongoDB
MongoDB的官方下载站是http://www.mongodb.org/downloads,可以去上面下载最新的程序下来. 在下载页面可以看到,对操作系统支持很全面,OS X.Linux.Windo ...
随机推荐
- css3 flex布局详解
原文链接: http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html?utm_source=tuicool https://www.cnblog ...
- int preg_match( string pattern
preg_match -- 进行正则表达式匹配.并且只匹配一次,注意与preg_match_all区别. int preg_match( string pattern, string subject ...
- 17.3.10--C语言运行的步骤
编译-->生成-->调试-->链接-->运行 编译就是:将你编写的C语言程序翻译成机器能识别运行的指令集 生成就是:根据编译完成的指令集制造出机器可以具体执行的指令序列 调试就 ...
- 01 语言基础+高级:1-10 JDK8新特性_day12【函数式接口】
day12[函数式接口] 主要内容自定义函数式接口函数式编程常用函数式接口 教学目标能够使用@FunctionalInterface注解能够自定义无参无返回函数式接口能够自定义有参有返回函数式接口能够 ...
- PAT Advanced 1069 The Black Hole of Numbers (20) [数学问题-简单数学]
题目 For any 4-digit integer except the ones with all the digits being the same, if we sort the digits ...
- Java之线程通信的应用:经典例题:生产者/消费者问题
/** * 线程通信的应用:经典例题:生产者/消费者问题 * * 生产者(Productor)将产品交给店员(Clerk),而消费者(Customer)从店员处取走产品, * 店员一次只能持有固定数量 ...
- js操作元素导致元素错位和大小改变
使用js循环的方式批量控制元素的大小时结果往往不尽如人意. 我总结了一条规律 在一个循环体内不可以同时存在一下两种操作,否则容易导致元素错位或大小改变: 1.对元素的offsetWidth.offse ...
- 简单的tab栏切换
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- POJ-2031 Building a Space Station (球的最小生成树)
http://poj.org/problem?id=2031 Description You are a member of the space station engineering team, a ...
- F - Fraction Formula Gym - 102307F
Mr. Potato Head has been promoted and now is a math professor at the UNAL. For his first course he i ...