我正在创建一个Helper方法来检查是否未设置时间戳(聚合查询除外)。当我尝试使其处理UTC + 0时出现了问题。
private string TimeNotSet(string fieldName)
{
return "'" + fieldName + "': { $not: { $elemMatch: { $ne: 0 } } }, ";// $elemMatch: { $ne: 0 } all documents where the array doesn't have at least one 0 value, aka where there is a greather than 0 value
// we don't want those so we add a $not clause
}
给出此数组:
"Time" : [
636686130499723800,
0
]
它不应返回包含Time数组的文档。但是确实如此。我想念什么?
编辑:更好 我意识到我可以查询
private string TimeNotSet(string fieldName)
{
return "'" + fieldName + "': [0, 0], ";
}
当数组为:
"Time" : [
0,
0
]
它应该返回文档,但是什么也不返回...