|
The new CRUD API allows you to use strings where a document is expected, and converts the string to a BsonDocument by assuming it is a JSON string and parsing it.
If we want to make it easy to provide BsonDocument values using strings in as many places as possible we might as well provide an implicit conversion from string to BsonDocument that parses the string.
Before actually implementing this we should consider whether this would result in a big hole in type safety. The issue is that if one accidentally writes code that uses a string where a BsonDocument is expected one would no longer get a compile time error (one would likely get a runtime error if the string doesn't happen to be a valid JSON document). On the other hand, being able to provide BsonDocuments using string constants would be incredibly convenient.
The other issue is that parsing strings to provide BsonDocument values involves the considerable overhead of parsing the string, and if we make it too easy to convert strings to BsonDocuments we may be encouraging our users to write inefficient code.
|