However when I use :attr.include with a string value it throws an InvalidType error:
~/myapp (development) > Post.where(:tags.include "nyt").to_a
NoBrainer::Error::InvalidType: Tags should be a array
from /Users/dpiemont/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/nobrainer-0.29.0/lib/no_brainer/document/types.rb:32:in `cast_user_to_model_for'
Finally, when I use :attr.include with a single-entry array value, it does not throw the validation error but returns no result (it is clear from the document pasted above this query should return the same result):
~/myapp (development) > Post.where(:tags.include ["nyt"]).to_a
[ 33.1ms] r.table("posts").order_by({"index" => r.asc(:id)}).filter {|var_22| var_22[:tags].map {|var_23| var_23.eq(["nyt"])}.contains(true)} -- perf: filtering without using an index
=> []
How can i form a Model.where() with :attr.include with a string value?
I'm trying to form a Model.where query using an array field (tags) and the :attr.include predicate.
When I use :attr.eq with an array value it returns the document in question:
However when I use :attr.include with a string value it throws an InvalidType error:
Finally, when I use :attr.include with a single-entry array value, it does not throw the validation error but returns no result (it is clear from the document pasted above this query should return the same result):
How can i form a Model.where() with :attr.include with a string value?