Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

metaData() for ODM ? Casting types for MongoDb

I have a string representating a value "8"(string) that I would like to store as an 8(int).

I can cast the value in beforeSave() but I would prefer to bind/cast to a different type as you can in a Database Model with the metaData() funciton.

Is this possible in ODM?



1.1k
Accepted
answer

It's currently not possible in the ODM, you have to use beforeSave()



24.4k