dresende/node-orm2

How to create indexes in table definitions?

becauseinterwebs opened this issue · 2 comments

How is an index created when defining tables?

After digging through the source, I have tried:

var User = db.define('user', {
    id        : { type: 'serial', key: true },
    userId    : { type: 'integer', required: true, mapsTo: 'user_id', index: true },
    ip        : { type: 'text', size: 15, required: true },
    createdAt : { type: 'date', time: true, mapsTo : 'created_at' },
    updatedAt : { type: 'date', time: true, mapsTo : 'updated_at' }
  }

I have also tried adding an indexes option. No matter what I try the index is not created and I do not see it anywhere in the documentation.

I am using node-orm2 v3.2.4

dxg commented

You will need to manually create the index in the database.