私信  •  关注

prasad_

prasad_ 最近创建的主题
prasad_ 最近回复了
4 年前
回复了 prasad_ 创建的主题 » 如何停止MongoDB数据库服务器在windows启动时自动运行?

每次我启动电脑,MongoDB数据库服务器就会自动启动

这是因为您已经将MongoDB安装为Windows服务。

你可以 Stop MongoDB Community Edition as a Windows Service

你可以 Remove MongoDB Community Edition as a Windows Service . 当你启动电脑时,这不会启动MongoDB you must manually start the MongoDB instance.

4 年前
回复了 prasad_ 创建的主题 » Mongodb查询与if条件匹配形成多个空值字段

这个 $match $expr 可以根据条件进行筛选: (sender.client = spec1 or receiver.client = spec1)

我的目标是过滤条件,如果(sender.client=spec1或 receiver.client=spec1)然后显示所有字段,即

您可以添加进一步的筛选器以匹配 name 字段(有两个“name”字段, sender.name receiver.name

var queryFilter = { $cond: {
                      if: { $or: [ 
                               { $eq: [ "$sender.client", "spec1" ] },
                               { $eq: [ "$receiver.client", "spec1" ] }
                            ]
                      },
                      then: true,
                      else: false
                 }
};

db.test.aggregate( [
{
    $match: { 
              $expr: { $eq: [ queryFilter,  true ],
              $or: [ { "sender.name" : "name3" }, { "receiver.name" : "name3" } ]  } 
    }
}
] )

匹配筛选器为: $expr: {...} $or: [...] .

$project )之后 $匹配

4 年前
回复了 prasad_ 创建的主题 » 如何在Mongodb中将每个数组字段匹配到其他字段

test 数组并将数组元素作为与 name $reduce 操作员)。

const test = [ { ... }, ... ]

db.test_coll.aggregate( [
  { 
      $addFields: { 
          testInform: { 
              $reduce: {
                  input: test,
                  initialValue: { },
                  in: {
                      $cond: [ { $eq: [ "$$this.name", "$name" ] }, 
                               { $mergeObjects: [ "$$this", "$$value" ] }, 
                               "$$value"
                             ]
                      }
               }
          }
      }
  }
] )