How to find documents with a specific field type?
It may happen to have different field types in a specific field like credit, and some of them are numeric and some of them string. In order to find
If you want to remove those fields, if applicable, use
#mongodb #mongo #type #field_type #remove #find
It may happen to have different field types in a specific field like credit, and some of them are numeric and some of them string. In order to find
NumberLong()
field types you can use $type
:db.users.find({credit: {$type: "long" }})
If you want to remove those fields, if applicable, use
remove
instead of find
to remove those documents that has wrong types. It is not sensible to do that for users document though, it just gives you the idea.#mongodb #mongo #type #field_type #remove #find