Open alanb1501 opened 10 years ago
Unfortunately this isn't possible at the moment as the default type is hard-coded into the database drivers themselves as INT(11) AUTO_INCREMENT
(for MySQL, the equivalent for PgSQL).
self.setEmotionalState(SAD_PANDA);
My suggestion (for the time being) would be to make changes to the node_modules/node-sql-ddl-sync/lib/Dialects/mysql.js file to reflect the datatype you wish to use - keep in mind that you will need to change it each time you update node-orm2
.
There has been some work done to add support for this, but it's not quite complete. The idea is to have:
db.define("person", {
identifier: { type: 'string', key: true}
});
If the table was created outside of ORM, it might just work as is.
Any updates on this?
Just found a way to do it.
orm.define('city', {
id: {
type: 'text',
required: true,
size: 100, // important or relationships won't work
},
name: String,
}, {
id: 'id', // important
});
Also try this (key: true
):
orm.define('city', {
id: {
type: 'text',
required: true,
size: 100, // important or relationships won't work
key: true
},
name: String,
});
Oh, so key
stands for PK? I didn't know that. It worked. Thanks.
It generates the table correctly, but we shouldn't really need the size
property.
I'd like to change the default id type to be BigInt.
I think I can do this by specifying the id property in each object, but DRY.