"$cond"
db.items.aggregate([
{ "$project": {
"name": 1,
"customfield": {
"$cond": {
"if": { "$eq": [ "$field1", "4" ] },
"then": 30,
"else": {
"$cond": {
"if": { "$eq": ["$field1","8"]},
"then": 25,
"else": 10
}
}
}
}
}},
{ "$sort": { customfield: 1 }},
{ "$limit":12 }
]);
随机推荐
- HTML5离线缓存问题
HTML5离线缓存问题 1.应用程序缓存 什么是应用程序缓存(Application Cache)? HTML5 引入了应用程序缓存,这意味着 web 应用可进行缓存,并可在没有因特网连接时进行访问. ...
- org.eclipse.swt.custom.StyledText.getScrollbarsMode()I
错误: org.eclipse.swt.custom.StyledText.getScrollbarsMode()I 解决方法: 1 卸载,并手工清除myeclipse全部文件 2 重新安装myecl ...
- 携程Ctrip DAL的学习 2
携程Ctrip DAL的学习 2 本人net开发菜鸟,原理请自行看github的官网源码. 我这里是简单的使用(helloworld的水平). 代码生成器的使用 详见 官网使用说明 注意的地方: 1 ...
- Web开发中20个很有用的CSS库
来源: 微信公众号文章 在过去的几年中,CSS已经成为一大部分开发者和设计者的最爱,因为它提供了一系列功能和特性.每个月都有无数个围绕CSS的工具被开发者发布以简化WEB开发.像CSS库,框架,应用这 ...
- JFinal - scheduler 插件做定时任务
我在项目中遇到一个需求:服务运行期间,数据库要定期去监测某表并且更新. 正好项目是使用 jfinal 做的,于是就用了 jfinal-scheduler 插件来解决(jfinal-scheduler ...
- redis安装
参考redis.io 安装步骤 下载,编译reids $ wget http://download.redis.io/releases/redis-3.0.6.tar.gz $ tar xzf red ...
- Grunt_1从安装开始创建一个基本的Grunt
Grunt的介绍:http://www.gruntjs.net/getting-started 文件架构:https://github.com/zhangsai521314/Grunt 1:安装Git ...
- /boot/grub/device.map【设备映射】
grub-install 安装 GRUB 在第一个硬盘的 MBR: # grub-install '(hd0)' grub-install 会先搜寻设备对应的文件(/boot/grub/device. ...
- js获取当前日期时间格式为“yyyy-MM-dd HH:MM:SS”
废话不多说,直接上代码! <!DOCTYPE html><html><head> <meta charset="utf-8"> ...
- ssh启动报错:org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
ssh项目启动报错: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection t ...