我具有这样的JSONB结构,请注意adults
是一个数组,我需要查询该数组中的每个成年人:
"passengers" => [
"adults" => [
"count" => 2,
"persons" => [
[
"name" => "foobar-adult",
"age" => date("Y") - 1975,
"birth_date" => "01-01-1975",
],
[
"name" => "other adult",
"age" => date("Y") - 1978,
"birth_date" => "02-02-1978",
],
],
]
]
,我需要按成人的名字查询外勤乘客。这是我的尝试:
Trip::where("passengers->adults->persons->name", "LIKE", "%foo%")->get();
但是,尽管有乘客叫“ foobar”,查询仍返回空。