module.exports = function (sequelize, DataTypes, options) { const model = sequelize.define("lock", { id: { type: DataTypes.STRING, defaultValue: function() { return options.generateUniqueId() }, primaryKey: true, unique: true }, userIdentifier: { type: DataTypes.STRING, allowNull: false }, url: { type: DataTypes.STRING, allowNull: false }, signature: { // Derivation from the master key... // TODO: Add validation... type: DataTypes.STRING, allowNull: false, unique: true }, message: { type: DataTypes.STRING, allowNull: false } }, { comment: "lock which our keys has access to" }); model.associate = (db) => { model.ExtendedPublicKey = model.belongsTo(db.ExtendedPublicKey); } return model; };