How to query a dynamic name from another object in mongoid
I am trying to do a query an object and the name is generated from another
embedded one, and check to see if a user is in it something like :
allOs = MyObject.all
myOs = []
allOs.each do |myO|
sths = myO.somethings
sths.each do |s|
name = "automated_#{s.title}"
myGroup = Group.where(name: name)
if myGroup.includes? current_user
myOS << myO
break
end
end
end
Is there anyway to do it in mongoid, cause this won't be query-able, and
it will load all the objects first which isn't optimized.
No comments:
Post a Comment