[odb-users] Transient class member that is only used to load an
expression
Tolga HOŞGÖR
fasdfasdas at gmail.com
Thu Apr 30 17:58:09 EDT 2015
Hello,
Thanks for ODB. It is a great, professional project.
I ended up with a case that I need to load an expression from the psql
database.
The situation is that I have a psql JSON field in a column. I have mapped
my JSON library and added the necessary traits specializations and it all
works fine.
But the thing is I don't want the huge JSON column to be converted to text
and then parsed by the C++ JSON library completely. I need to add that JSON
class member to a lazy loading section and use only one field of it most of
the time. For that I want to create another (kind of a) transient
std::string class member that loads with 'table.JSON_column->>'json-key'
expression in the SELECT query field when I load the object. Obviously it
should not have an actual column on the database side.
I can actually make the variable eager loading manual updating section and
use column() with that expression but the generated table SQL file
obviously has that expression as a column that should be created on the
table.
Is there a correct way to do this?
Regards,
Tolga.
More information about the odb-users
mailing list