[MongoDB] 特定のテキストフィールドが x 文字以上の document を取得する query

MongoDB で特定のテキストフィールドが x 文字以上の document を取得する query をご紹介します。

MongoDB | モンゴディービー

db.users.find( { name : { $ne: null }, $where: "this.name.length > 5" } )

ポイントは name フィールドに値が存在する場合のみ $where で長さをチェックしている点です。