0

ユーザーを含む住居オブジェクトがあります。ただし、私のアプリケーションでは、アプリケーションがユーザーを認識しているが、ユーザーがメンバーである住居を認識していないというエッジケースがあります。ユーザーの一意の ID に基づいて親住居オブジェクトを取得する方法はありますか?

class User 
    include Mongoid::Document

    field :email, type: String
    field :firstName, type: String
    field :lastName, type: String
end

class Residence
    include Mongoid::Document

    field :name, type: String
    field :updateTime, type: DateTime

    embeds_many :groceryLists
    embeds_many :events
    embeds_many :messages
    embeds_many :users
end

次のようなもの:

user_id = foo
Residence.is_any(users._id: user_id)
4

1 に答える 1