thejsj / rethinkdb-init

Create all RethinkDB databases, tables and indexes automatically through a schema object.
https://www.npmjs.com/package/rethinkdb-init
53 stars 15 forks source link

Compound indexes #20

Open ghost opened 7 years ago

ghost commented 7 years ago

Do you have support for compound indexes?

// Create a compound secondary index based on the first_name and last_name attributes
r.table("users").indexCreate(
    "full_name", [r.row("last_name"), r.row("first_name")]
).run(conn, callback)
Xstoudi commented 6 years ago

Up !

blakek commented 6 years ago

I had the same question. It seems to just work if you follow the documentation for indexFunction.

For example, this seems to work:


await r.init(dbOptions, [
    {
      name: 'users',
      indexes: [
        {
          indexFunction: [r.row('last_name'), r.row('first_name')],
          name: 'full_name'
        },
        'username',
        'someOtherIndex'
      ]
    }
  ]);