查找mongodb不能用作

时间:2018-01-13 09:37:27

标签: mongodb

我用数据创建的这个系列的订单和骑手 骑手

[
  {
    "_id": "5a55b5fb99391a1694fa4541",
    "name": "rider4",
    "email": "rider4@gmail.com",
    "mob": "3d4",
    "city": "Sotland",
    "address": "UK",
    "postcode": "411041",
    "password": "123456",
    "__v": 0,
    "device_token": "d12223",
    "status": false
  },
  {
    "_id": "5a55b5e399391a1694fa453f",
    "name": "rider2",
    "email": "rider2@gmail.com",
    "mob": "34",
    "city": "Sotland",
    "address": "UK",
    "postcode": "411041",
    "password": "123456",
    "__v": 0,
    "device_token": "12223",
    "status": false
  },
  {
    "_id": "5a55b5a299391a1694fa453a",
    "name": "rider3",
    "email": "rider3@gmail.com",
    "mob": "2",
    "city": "Sotland",
    "address": "UK",
    "postcode": "411041",
    "password": "123456",
    "__v": 0,
    "device_token": "123",
    "status": false
  },
  {
    "_id": "5a5453a76b7be60004bc8e67",
    "name": "rider1",
    "email": "rider1@gmail.com",
    "mob": "62345674d890",
    "city": "Sotland",
    "address": "UK",
    "postcode": "411041",
    "password": "123456",
    "__v": 0,
    "device_token": "123",
    "status": false
  }
]

订单集合有:

    {
        "_id": "5a599b750cdf310004334087",
        "orderNumber": "1",
        "riderId": "5a55b5e399391a1694fa453f"
    },
    {
        "_id": "5a599b600cdf310004334086",
        "orderNumber": "1",
        "riderId": "5a55b5a299391a1694fa453a"
    },
    {
        "_id": "5a599b380cdf310004334085",
        "orderNumber": "1",
        "riderId": "5a5453a76b7be60004bc8e67"
    },
    {
        "_id": "5a599b0c0cdf310004334084",
        "orderNumber": "1",
        "riderId": "5a55b5fb99391a1694fa4541"
    },
    {
        "_id": "5a599af30cdf310004334083",
        "orderNumber": "1",
        "riderId": "5a55b5fb99391a1694fa4541"
    },
    {
        "_id": "5a599ad90cdf310004334082",
        "orderNumber": "1",
        "riderId": "5a55b5e399391a1694fa453f"
    },
    {
        "_id": "5a599ac00cdf310004334081",
        "orderNumber": "1",
        "riderId": "5a55b5a299391a1694fa453a"
    },

我正在运行这些查询:

db.getCollection('orders').aggregate([
              {$match:{'order_created':"1/13/18" }},
               {$lookup:{"from":"rider","localField":"riderId", 
"foreignField":"RID","as":"rider"}}])

显示输出

rider : 0

0 个答案:

没有答案