NoBrainerORM / nobrainer

Ruby ORM for RethinkDB
http://nobrainer.io/
Other
387 stars 49 forks source link

Implements `index: { defined: true }` index #293

Closed zedtux closed 1 year ago

zedtux commented 1 year ago

This PR adds the defined: true option to the index method allowing to only index documents having the given field.

class MyDoc
  include NoBrainer::Document

  # Using the field options
  field :field1, index: { defined: true }
  field :field2
  field :field3

  # Using the index method
  index :field2, defined: true
end

The following queries will use the above declared indexes:

MyDoc.where(:field1.defined => true).count

MyDoc.where(:field1.defined => true, :field2.defined => true).count
zedtux commented 1 year ago

This doesn't work on RethinkDB side without a clear understanding of the issue (discussed on Slack) therefore I'm closing it.