dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 376 forks source link

How to create indexes in table definitions? #799

Closed becauseinterwebs closed 3 years ago

becauseinterwebs commented 7 years ago

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.

becauseinterwebs commented 7 years ago

I am using node-orm2 v3.2.4

dxg commented 7 years ago

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