Skip to content

Instantly share code, notes, and snippets.

@moonglum
Created November 24, 2012 14:33
Show Gist options
  • Save moonglum/4139906 to your computer and use it in GitHub Desktop.
Save moonglum/4139906 to your computer and use it in GitHub Desktop.
I don't really understand this behavior
relation = base_relation.restrict do |r|
r.name.eq "Cologne"
end.sort_by do |r|
[ r.name, r.country ]
end
mongo_visitor = Veritas::Adapter::Mongo::Visitor.new relation
p mongo_visitor.query
#=> {:name=>"Cologne"}
@dkubb
Copy link

dkubb commented Nov 25, 2012

@moonglum btw, you can also write the restrict part like base_relation.restrict(:name => 'Cologne'), this is a short cut for the common case where you just want to do an equality match of one or more attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment