Definition
The MongoDB for IntelliJ Plugin examines the document fields in queries to ensure that the data types match. For example, if you use a String
field in an equality comparison, or an insert or update operation, the plugin examines the field value to ensure the type is also a String
.
If the value type is invalid, the plugin shows a warning that indicates the type cannot be assigned.
To resolve the warning, change the field value to match the expected type. If the field is dynamically typed and strict typing rules aren't applied, you can ignore the invalid type warning.
Example
In the following example Java code snippet, the trip_status
field type is String
, but the Filters
operation attempts to perform an equality comparison with an Integer
value 1324324
:
public List<Document> findCompletedTripsByDriver( String driverId ) { return trips.find( Filters.and( Filters.eq( fieldName: "trip_status", value: 1324324 ) Filters.eq( fieldName: "driver_id", driverId ) )).into( new ArrayList<> () ); }
Because value
is an Integer
but trip_status
is a String
in the MongoDB documents, the side panel shows a warning about the invalid type under Correctness Warnings:

To resolve the invalid type, change the value to a String
. For example: "start"
.