NoBrainerORM / nobrainer

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

Support arbitrary index directly on the field #172

Open robertjpayne opened 8 years ago

robertjpayne commented 8 years ago

I want to create a tags index where the index is lowercased but the field is stored as is. Basically Twitter style where tags can be whatever case and appear in the case the author wrote them but querying is done entirely lowercased.

Currently NoBrainer complains if you do:

field :tags, type: Array
index :tags, lambda { |doc|
  doc[:tags].map { |tag| tag.downcase }
}, multi: true

I'm a bit OCD here and would like the field/index name to be the same so I attempted to move the index directly into the field declaration but then I cannot specify it's a multi index.

Is this something that could be supported easily? Otherwise I can just suffice with custom index name :)

nviennot commented 8 years ago

Perhaps it would be a good idea to not have to specify a name and let nobrainer pick a default name (like simple and compound indexes). In the meantime you can name it ltags ;)