在$ lookup mongodb中预测一些字段

时间:2017-01-10 14:55:13

标签: mongodb lookup

https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/

整个文件被写入" inventory_docs"领域。 有没有办法缩小或$项目将要写入" inventory_docs"

的文件
{
  "_id": 1,
   "item": "abc",
  "price": 12,
  "quantity": 2,
  "inventory_docs": [
    { "_id": 1, "sku": "abc", description: "product 1", "instock": 120 }
  ]
}

我所说的是,而不是这个;

{
  "_id": 1,
  "item": "abc",
  "price": 12,
  "quantity": 2,
  "inventory_docs": [
    { "_id": 1, "instock": 120 }
  ]
}

我想将其创建为;

formatTime(seconds: number): string {

    let minutes: any = Math.floor(seconds / 60);
    let secs: any = Math.floor(seconds % 60);

    if (minutes < 10) {
        minutes = '0' + minutes;
    }

    if (secs < 10) {
        secs = '0' + secs;
    }

    return minutes +  ':' + secs;
}

我该怎么做?

0 个答案:

没有答案