[英]How do you query a Mongo db for rows containing a column with a specific type?
I have a collection that has ended up with a column containing an updated timestamp, sometimes as a text field, sometimes as a date field.我有一个以包含更新时间戳的列结束的集合,有时作为文本字段,有时作为日期字段。 I am looking for the syntax to execute a query to find all rows that contain that field as a date type.我正在寻找执行查询的语法,以查找包含该字段作为日期类型的所有行。
You can use $type
with $not
您可以将$type
与$not
一起使用
Checking the not
scenario.检查not
场景。 If type is not of string, then consider that doc.如果类型不是字符串,则考虑该文档。
db.collection.find({
"key": {
$not: {
$type: "string"
}
}
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.