Here is the JSON value in the datatable column things:
data
things
{a: [{b: 1}, {b: 2}]}
I can get everything thingscontaining bequal to 1 with a raw query like this:
b
select * from things where data @> '{ "a": [{"b": 1}] }';
I know that we can run a query with Laravel using JSON, where is the sentence with Laravel: https://laravel.com/docs/5.4/queries#json-where-clauses . I can write something like:
Thing::where('a->c', 'foobar');
But can I write where to check if it contains a {b: 1}, as in a raw query with Laravel Query Builder?
a
{b: 1}
Laravel ( ) -> ->> "JSON where clauses" ( , PostgreSQL). , .
->
->>
PostgresGrammar @> <@ , :
PostgresGrammar
@>
<@
Thing::where('data', '@>', '{"a":[{"b":1}]}')
Source: https://habr.com/ru/post/1676451/More articles:OpenCV UIImageToMat not working in xcode - c ++Formulation of a static member of a template template - c ++Pug: force add space to end of line - whitespacehow do I display pdf in html (responsive solution / crossbrowser) - androidWhat is a cross-domain issue? - javascriptИзмените код JavaScript для страницы, если пользователь изменит ее размер - javascriptAxioms of functional programming - functionThe problem of deserialization (recursion object) using Jackson JSON - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1676455/setorder-danish-letters-or-custom-ordering-of-letters-in-a-data-table&usg=ALkJrhgGpu3qzXFwbk0WcBB-O5T8Xv_E4QCan you have multiple cursors for the same thread? Will it be thread safe? - c ++All Articles