You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 17, 2020. It is now read-only.
Model.fields{foo: 'json'};Model.table='data';Model.fetch({fields: [{foo: {bar: true}},{foo: {quux: true}}]});// or with an alias:Model.fetch({fields: {alias1: {foo: {bar: true}},alias2: {foo: {quux: true}}}}});
that yields:
-- without aliases:SELECT"foo"->'bar'as"foo.bar", "foo"->'quux'as"foo.quux"FROM"data";
-- with an alias:SELECT"foo"->'bar'as"alias1", "foo"->'quux'as"alias2"FROM"data";
however, since using an object allows one to use multiple keys, one could add multiple json paths for only one alias when using the aliased form which would result in undesired/unexpected behaviour. therefore, it makes sense to enforce a single key per object (in both the non-aliased and aliased forms for conformity).
note that the field value should get automatically JSON-parsed so it shouldn't be necessary to use the ->> operator: