Reputation: 4429
Imagine the following Model:
class Model
...
field :things, type Hash
...
end
I would like then to be able to search for documents which has a specific attribute inside the things
hash like so:
model = Model.where('things.order_id' => 9689689)
or
model = Model.where('things.order_id' => 9689689).all
But that doesn't find the document(s) I'm looking for. Neither does the following:
model = Model.elem_match(inside: {order_id: 116152})
nor this one:
model = Model.where(:inside.elem_match => {order_id: 116152})
What am I missing here?
Please note this is not an embedded document, but simply a model which contains hashes (though would be nice to find a way to do similar searches in embedded models).
Any ideas?
Upvotes: 0
Views: 26