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};

随机推荐

  1. [转]用Gson来解析Json数据

    转自太阳尚远的博客:http://blog.yeqianfeng.me/2016/03/02/use_gson_to_parse_json/ 在我们实际开发中像Json和XML这两种格式的数据是最常见 ...

  2. SQL Server 数据的创建、增长、收缩

    第一步: create database Studio         on primary          (name = 'Studio',filename='E:\DB\Studio.mdf' ...

  3. linux查看网卡个数及速度

    # lspci | grep Ethernet03:00.0 Ethernet controller: Broadcom Corporation NetXtreme II BCM5708 Gigabi ...

  4. C# 堆栈的数据结构 (二)

    堆栈是一种常用的数据结构,并且是线性表操作的子集,即操作受限的线性表.因此需要用到Clist 线性表类 public class CStack { private Clist m_List;//创建链 ...

  5. InputStream和OutputStream

    1.在java中stream代表一种数据流(源),javaio的底层数据元,---(想像成水龙头) 2.任何有能力产生数据流(源)的javaio对象就可以看作是一个InputStream对象既然它能产 ...

  6. Mobile Service更新和 Notification Hub 对Android的支持

    本周,我们要推出一些更新,使移动服务成为移动应用程序更强大.更灵活的后端,同时推出一个与移动服务或网站结合使用的免费 20MB SQL 数据库,并且将支持通过Notification Hub中的 GC ...

  7. Windows下使用XManager访问Ubuntu 11.04的设置方法

    1.Download the attached file and upload it to the server. And, enter the following command to update ...

  8. 在JavaScript的数组中进行数组元素查找和替换(JS的indexOf等)

    <html> <head> <title> Extend JavaScript Array Method </title> <script lan ...

  9. heap creation

    There two methods to construct a heap from a unordered set of array. If a array has size n, it can b ...

  10. CodeForces - 508D Tanya and Password(欧拉通路)

    Description While dad was at work, a little girl Tanya decided to play with dad characters. She has ...