"$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 }
]);
随机推荐
- $.ajax()方法所有参数详解;$.get(),$.post(),$.getJSON(),$.ajax()详解
[一]$.ajax()所有参数详解 url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. type: 要求为String类型的参数,请求方式(post或get)默认为get.注 ...
- centos 带S权限的二进制
早上写的一个用find查找带S权限的,感觉不记一下可惜了. [root@iZ28wg1kditZ ~]# find / -type f -exec ls -al {} \;|awk 'BEGIN {p ...
- BirdError
//#include<curses.h> #include<stdlib.h> #include<signal.h> #include<time.h> ...
- Centos中tomcat7指定jdk
服务器上默认的jdk是1.8的,但是我想我的tomcat指定一个自定义的jdk怎么办呢,莫急,待老夫慢慢道来. 1.需要有一个除默认外的jdk的安装包(不用配置任何环境变量),如下图: 2.进入tom ...
- iOS 消息推送报错NSCocoaErrorDomain Code=3000
转自: http://www.cnblogs.com/zxykit/p/5207498.html Xcode7推送报错.Error Domain=NSCocoaErrorDomain Code=300 ...
- Sublime Text 配置记录
sublime userSetting sublime theme sublime plug sublime userSetting 对sublime的配置 { "color_scheme& ...
- mysql事务处理
事务处理能保证所有的sql操作一次性完成或回滚,mysql默认的MyISAM表类型是不支持事务处理的,如果需要做事务处理,需要把表类型换成InnoDB <?php $dsn='mysql:hos ...
- svn 版本控制
首先来下载和搭建SVN服务器. Subversion已经迁移到apache网站上了,下载地址: http://subversion.apache.org/packages.html windows操作 ...
- linux学习网站分享
http://www.zhihu.com/question/19895288 http://linux.vbird.org/ 两个linux学习的网页存起来,以后学习.
- [WPF]ComboBox.Items为空时,点击不显示下拉列表
ComboBox.Items为空时,点击后会显示空下拉列表: ComboBox点击显示下拉列表,大概原理为: ComboBox存在ToggleButton控件,默认ToggleButton.IsChe ...