I'm just getting to grips with DBIx::Class and I'm trying to get it to work with jsonb data types in PostrgeSQL. I've got a simple select statement that returns a json string that I convert into a hash to pass to a template.
Simplified database:Dancer2 code:Column | Type | Modifiers + --------+---------+--------------------------------------------------- +--- id | integer | not null default nextval('details_id_seq'::regclas +s) data | jsonb |
Is there any way I can run queries based on keys/values in the json column using DBIx::Class, for instance where email = 'foo@...', or specifiy which key/vals I want to return?... my $rs = schema->resultset('Detail') ->find({id => route_parameters->get('code')}); if ($rs) { #return to_dumper(from_json($rs->data)); template 'form', {'form' => from_json($rs->data)}; ... Decoded json: $VAR1 = { 'order_code' => '0165-02675-4565', 'email' => +'foo@test.com', 'price' => '15', 'title' => 'Mt Thing XYZ' };
I am doing this as I need a way to handle potentially unstructured data and I am restricted to using Postgres. I'm quite new to DBIx::Class, maybe this isn't the best tool to use in this case but I would appreciate any help.
Just found DBIx::NoSQL, which looks like it might be what I need but the docs say it's still in beta which is a concern.
In reply to Using DBIx Class with json data types by epoch1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |