Postgresql 如何在Postgres、Activerecord和Rails 5中查询空jsonb数组

Postgresql 如何在Postgres、Activerecord和Rails 5中查询空jsonb数组,postgresql,activerecord,ruby-on-rails-5,jsonb,Postgresql,Activerecord,Ruby On Rails 5,Jsonb,我有一个Post模型,其列由以下迁移定义: add_column :posts, :comments, :jsonb, default: [] add_index :posts, :comments, using: :gin 我想知道要运行的查询,以便统计所有帖子,它们的默认空数组为注释 Post.where("comments = '[]'").count

我有一个
Post
模型,其列由以下迁移定义:

add_column :posts, :comments, :jsonb, default: []

add_index :posts, :comments, using: :gin
我想知道要运行的查询,以便统计所有
帖子
,它们的默认空数组为
注释

Post.where("comments = '[]'").count