我添加了要在其中存储ID的jsonb字段。
接下来,我需要通过该字段的内容对记录进行“搜索”。
[在所有地方,包括文档(link),我都看到了此运算符-@>
。但我没有设法使用它:
User.where.not("migration_ids @> ?", 1)
ActiveRecord::StatementInvalid (PG::UndefinedFunction: ERROR: operator does not exist: jsonb @> integer)
LINE 1: ...s".* FROM "users" WHERE NOT (migration_ids @> 1) LIMI...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
请告诉我,如何正确处理?
这应该有效User.where.not("migration_ids @> ?", "1")