mfenniak / rethinkdb-net

A C# / .NET client driver for RethinkDB.
Other
247 stars 37 forks source link

Implemented Compound Indexes #229

Closed nkreipke closed 8 years ago

nkreipke commented 8 years ago

Greetings!

I wanted to use compound indexes with the driver, but that feature was not implemented. Turns out it works by providing an array as an index:

Person.Db.GetAll<Person, string[]>(new[] { "a", "b", "c" }, "AbcIndex");

This is kind of awkward and makes it impossible to use compound indexes with varying types (object[] does not work). Furthermore, there was no way to programmatically create a compound index.

I extended the driver with a way to define those compound indexes. Here is how you can use it with GetAll:

Person.Db.GetAll<Person, CompoundIndexKeys>(CompoundIndexKeys.Make("a", "b", 10, true, 2.5), "AbcIndex");

And here is how you can create new compound indexes:

Person.Db.IndexCreate("AbcIndex", CompoundIndex<Person>.Make(a => a.SomeString, a => a.SomeOtherString, a => a.SomeNumber, a => a.SomeBool, a => a.SomeFloatingPoint));

Kind regards, Nico