You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Mongoid
one post has_many attachments
I am trying to do a query for only posts with attachments
ie, something along the lines of:
posts.where(:attachments.length.gte => 1 ).count
this of course does not work, but is there anyway to achieve this with
a criteria query without reverting to something like:
@imageable.posts.each do |post|
if post.attachments.length > 0
@posts << post
end
end
Thanks
Durran Jordan
unread,
Oct 16, 2011, 2:18:07 AM10/16/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mon...@googlegroups.com
Unfortunately MongoDB does not provide a length comparison of arrays in it's query language, but you could achieve it with javascript. (Note that it would result in a full scan of the collection on the db side):