我正在使用Postgres的json数据类型,但想要使用嵌套在json中的数据进行查询/排序.
我想在json数据类型上使用.where进行排序或查询.例如,我想查询跟随者数> 500的用户,或者我想通过关注者或跟随计数来订购.
谢谢!
例:
model User
data: {
"photos"=>[
{"type"=>"facebook", "type_id"=>"facebook", "type_name"=>"Facebook", "url"=>"facebook.com"}
],
"social_profiles"=>[
{"type"=>"vimeo", "type_id"=>"vimeo", "type_name"=>"Vimeo", "url"=>"http://vimeo.com/", "username"=>"v", "id"=>"1"},
{"bio"=>"I am not a person, but a series of plants", "followers"=>1500, "following"=>240, "type"=>"twitter", "type_id"=>"twitter", "type_name"=>"Twitter", "url"=>"http://www.twitter.com/", "username"=>"123", "id"=>"123"}
]
}
Run Code Online (Sandbox Code Playgroud)