-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Hi,
I propose UNIQUE support, SQLite will automatically create INDEX.
SQLite3.prototype.propertySettingsSQL = function (model, prop) {
var p = this._models[model].properties[prop];
return datatype(p) +
//// In case in the future support user defined PK, un-comment the following:
// (p.primaryKey === true ? ' PRIMARY KEY' : '') +
// (p.primaryKey === true && p.autoIncrement === true ? ' AUTOINCREMENT' : '') +
(p.allowNull === false || p['null'] === false ? ' NOT NULL' : ' NULL') +
(p.unique === true ? ' UNIQUE' : '') +
(typeof p.default === "number" ? ' DEFAULT ' + p.default :'') +
(typeof p.default === "string" ? ' DEFAULT \'' + p.default + '\'' :'');
};Example usage:
var Data = schema.define('Data', {
// num: { type: Number, primaryKey: true, autoIncrement: true},
key: { type: String, index: true, unique: true, null: false },
value: String
});This will generate:
CREATE TABLE `Data` (
`id` INTEGER PRIMARY KEY,
`key` VARCHAR(255) NOT NULL UNIQUE,
`value` VARCHAR(255) NULL
);Metadata
Metadata
Assignees
Labels
No labels