【问题标题】:How to use MongoDB aggregation to find document based on Binary ID如何使用 MongoDB 聚合根据二进制 ID 查找文档
【发布时间】:2022-07-22 06:12:43
【问题描述】:

我想知道是否可以使用 MongoDB 聚合(即使用指南针)按二进制值进行过滤。在我的问题中,我试图根据文档是否包含具有特定二进制 id 的字段来查找文档。我试过了:

 {$match : { FieldWithBinaryValues: {$elemMatch : {$eq : Binary('extrOROmZqRu3ToCFD/b2Q==', 3)}}}}

没有任何成功(该字段是二进制 ID 的数组,因此是 elemMatch)。

【问题讨论】:

    标签: mongodb binary aggregation


    【解决方案1】:

    请尝试以下方法: {$match : { FieldWithBinaryValues: {$elemMatch : {$eq : BinData(3,'extrOROmZqRu3ToCFD/b2Q==')}}}}

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-29
      • 1970-01-01
      • 1970-01-01
      • 2019-01-14
      • 2011-06-14
      • 2017-11-08
      • 2017-05-08
      • 2020-10-10
      相关资源
      最近更新 更多