DBAtlas · Database operations atlas

14: TypeMismatch

MongoDB

What does it mean?

The type of the supplied value does not match the expected BSON type. A different data type was expected for a field or argument.

Why does it happen?

Text supplied where a number is expected, a string used instead of a date, a single value sent where an array is expected, an argument of the wrong type passed to an aggregate/query operator, or type inconsistency in the schema.

How to fix it

Supply the correct BSON type for the field/argument. Convert types in the application layer before saving data (e.g. write numbers as actual Number values). Verify the types expected by query and aggregate operators. Enforce type consistency with a schema validator.

Open in DBAtlas →

More from this engine