美文网首页
mongod的实际应用

mongod的实际应用

作者: Biao_349d | 来源:发表于2021-09-25 16:44 被阅读0次

    api 链接 https://www.docs4dev.com/docs/zh/mongodb/v3.6/reference/reference-method-db.collection.aggregate.html

    查询条件链接 https://www.docs4dev.com/docs/zh/mongodb/v3.6/reference/reference-operator-query.html

    // 查询指定字段所形成的数组;

    { "_id": 1, "dept": "A", "item": { "sku": "111", "color": "red" }, "sizes": [ "S", "M" ] }
    { "_id": 2, "dept": "A", "item": { "sku": "111", "color": "blue" }, "sizes": [ "M", "L" ] }
    { "_id": 3, "dept": "B", "item": { "sku": "222", "color": "blue" }, "sizes": "S" }
    { "_id": 4, "dept": "A", "item": { "sku": "333", "color": "black" }, "sizes": [ "S" ] }
    
    
    db.inventory.distinct( "dept" )
    
    [ "A", "B" ]
    
    

    https://www.docs4dev.com/docs/zh/mongodb/v3.6/reference/reference-command-distinct.html

    update 更新或插入字段

    await DB.Stocktradingday.update(
            {
              id: 1
            },
            {
              $set: {
                datelist: tradingDayList
              }
            },
            {
              upsert: true
            }
          )
    
    

    查询指定条件并且返回某个字段值的列表

    let hardenSymbolList = await stockDailyHisDb.User.distinct('symbol', {
          date: {
            $eq: startTime
            // $lte: startTime
          },
          // 涨幅小于9.5
          percent: {
            $gte: 9.5
          }
        });
    
    

    匹配符号

    https://www.docs4dev.com/docs/zh/mongodb/v3.6/reference/reference-operator-aggregation-avg.html

    相关文章

      网友评论

          本文标题:mongod的实际应用

          本文链接:https://www.haomeiwen.com/subject/wzpxnltx.html