$in的方法总结
Ad.find({"_id":{$in:datas}},function(err,item){
if(err) console.log(err);
//console.log(item);
res.json(item);
})
datas要求返回是一个数组;
有几点不解之处;
1、传入的数组条件,如果是重复的,不如传入n个相同的ID,会自动去重返回一个无重复的数组;
2、如果其中某个id值不存在返回的数组是否有什么区别;比方说有一个空选项;
3、熟练这种写法;_id:{$in:datas};
随机推荐
- sudo apt-get update
要用apt-get这种方式安装LAMP时,最好先运行下面在命令升级自己的系统这样是为了更新源,而如果你找的源不好,可能安装LMAP失败.#sudo apt-get update 获得最近的软件包的列表 ...
- Spring摘记
spring工作机制及为什么要用? 1.spring mvc请所有的请求都提交给DispatcherServlet,它会委托应用系统的其他模块负责负责对请求进行真正的处理工作.2.Dispatcher ...
- 浅析C++内存分配与释放操作过程——三种方式可以分配内存new operator, operator new,placement new
引言:C++中总共有三种方式可以分配内存,new operator, operator new,placement new. 一,new operator 这就是我们最常使用的 new 操作符.查看汇 ...
- Object.prototype.toString.call() 区分对象类型(判断对象类型)
在 JavaScript 里使用 typeof 来判断数据类型,只能区分基本类型,即 “number”,”string”,”undefined”,”boolean”,”object” 五种.对于数组. ...
- NHibernate 3.3
今天试了一下NHibernate 3.3比之前的版本简单,只需要引入两个dll,这两个dll分别是:Iesi.Collections.dll和NHibernate.dll 通过 http://nhfo ...
- CSS的W3C标准的盒子模型和低版本IE浏览器的盒子模型
CSS中盒子模型的组成由内容区(content).内边距(padding).边框(border).外边距(margin)组成.内边距可细分为 padding-top.padding-right.pad ...
- floyd学习中
#include<iostream> #include<math.h> #include<stdio.h> using namespace std; //long ...
- Qt 圆角矩形+鼠标左键拖动窗口
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWind ...
- leetcode Maximum Depth of Binary Tree python
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = ...
- http request parameter
http request parameter add htmlspecialchars host?vendor_id=1000000&q=Some%20children%20wish%20to ...