Is the expectedType parameter available on updateOne(...)?

I’ve seen in the mongosh documentation that you can provide a type hint when inserting data into a collection:

db.types.insertOne(
   {
       "_id": 1,
       "value": Int32("1"),
       "expectedType": "Int32"
   }
)

Unfortunately, that expectedType parameter doesn’t seem to be documented anywhere, in particular, it’s not on the reference manual page for insertOne(...).

Is the expectedType parameter still supported? And if so, can it also be used for updateOne(...)? (How?)

Last but not least, can someone please let me know how to find documentation on it? :innocent:

It is not documented because it is not a parameter. It is there as an example so that you can verify in Compass or mongosh (with $type) that the store value is really the expectedType. The hint mentioned in your first link is the constructor Int32() as indicated by the sentence:

The Int32() constructor can be used to explicitly specify 32-bit integers.

1 Like

Ouch. :grin:

Thanks. Somehow, I read that as being a param, when in fact, it was part of the first param’s JSON block… :slight_smile:

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.