MongoDB $type 操作符
$type 按字段类型过滤:可用类型别名(string、int、bool、double…)或 BSON 数字编号。
Key PointsMongoDB,$type,类型过滤,BSON
讲解
$type 按字段类型过滤:可用类型别名(string、int、bool、double…)或 BSON 数字编号。
示例
JavaScript
db.site.find({ title: { $type: "string" } })
db.site.find({ alexa: { $type: "int" } })Output
-- 返回 title 为字符串类型的文档讲解
$type 按字段类型过滤:可用类型别名(string、int、bool、double…)或 BSON 数字编号。
示例
JavaScript
db.site.find({ title: { $type: "string" } })
db.site.find({ alexa: { $type: "int" } })Output
-- 返回 title 为字符串类型的文档