Skip to content

Query by responsible_id #131

Description

@phildionne

Let's say we have something like:

Logidze.with_responsible(user.id) do
  Post.create
end

It would be really useful to be able to find records by their responsible_id:

Post.where(log_data: { responsible_id: user.id })

Otherwise to be able to do this you have to add a real responsible_id column on each of the models and duplicate the with_responsible logic with a slight twist.

Since log_data is JSONB, I think something like this (pseudo-code) is doable, but it requires to know the structure of log_data:

Post.where("(log_data -> 'h' @> '[r ->> ?]')", user.id)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions