2019-11-23 22:34:59 +02:00

39 lines
1.0 KiB
JavaScript

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;
};