Closed kuldeepaggarwal closed 9 years ago
In this line, I need to manually loop over the column and get the array of values and also need to apply without_ordering
and raw
clause.
I see. the API is consistent with http://rethinkdb.com/api/ruby/pluck/ and http://rethinkdb.com/api/ruby/without/
So the API is consistent with the RethinkDB API, and not with ActiveRecord. I'm not sure going away from the RethinkDB API is a good choice. I'd rather provide an option to pluck()
to provide the behavior you need. Any suggestions?
But then I should not need to use without_ordering
clause.
Adding without_ordering
is not necessary. The default ordering is only there to provide a deterministic response.
So you have two ways to achieve what you want:
name
is called on each returned object, giving you the ability to go through user defined getters.def names
pluck(:id, :name).map(&:name)
end
def names
NoBrainer.run { rql_table.map { |doc| doc['name'] } }
end
Why ordering is there in every query?
So results are deterministic. Further details at http://nobrainer.io/docs/fields/#primary_key
Can you provide a more detailed explanation?