diff options
| author | Ran Guin <[email protected]> | 2021-05-11 18:28:25 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2021-06-04 22:37:02 -0700 |
| commit | 2e18dc7a532d07d6e53581e5076c7d61a45d6d65 (patch) | |
| tree | b6bbd72253c806af56d3640f9e97414f6f4cba19 /db/normalized/users.js | |
| parent | 421accbfbc0a1add93f7704e657ae93f2d836b82 (diff) | |
| download | coinos-server-2e18dc7a532d07d6e53581e5076c7d61a45d6d65.tar.gz coinos-server-2e18dc7a532d07d6e53581e5076c7d61a45d6d65.zip | |
add first draft of normalized schema
Diffstat (limited to 'db/normalized/users.js')
| -rw-r--r-- | db/normalized/users.js | 201 |
1 files changed, 201 insertions, 0 deletions
diff --git a/db/normalized/users.js b/db/normalized/users.js new file mode 100644 index 00000000..fb30a550 --- /dev/null +++ b/db/normalized/users.js @@ -0,0 +1,201 @@ +const { DataTypes } = require('sequelize'); + +const attributes = { + id: { + type: DataTypes.INTEGER(11), + primaryKey: true, + autoIncrement: true, + allowNull: false + }, + uuid: { + type: DataTypes.STRING(255), + allowNull: false, + comment: "unique UUID as more secure reference" + }, + password: { + type: DataTypes.STRING(255), // Encrypted Password type ?? + allowNull: false, + validate: { + len: [8, 255] + } + }, + email: { + type: DataTypes.STRING(255), + validate: { + isEmail: true + } + }, + sms: { + type: DataTypes.STRING(255), + validate: { + is: /^[0-9]+$/ // replace spaces, brackets, dashes dynamically prior to create + } + }, + email_verified: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: false, + }, + sms_verified: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: false, + } +} + +const options = { + tableName: "users", + comment: "", + timestamps: true, + createdAt: 'created_at', + updatedAt: 'updated_at', + indexes: [ + {fields: ['uuid', 'email']} + ] +}; + +db["User"] = db.define("users_model", attributes, options); + + + // *** Move to user_preferences *** +// unit: { +// type: DataTypes.STRING(255), +// allowNull: true, +// defaultValue: 'SAT', +// primaryKey: false, +// autoIncrement: false, +// comment: null, +// field: "unit" +// }, +// currency: { +// type: DataTypes.STRING(255), +// allowNull: true, +// defaultValue: "CAD", +// primaryKey: false, +// autoIncrement: false, +// comment: null, +// field: "currency" +// }, +// currencies: { +// type: DataTypes.JSON, +// allowNull: false, +// defaultValue: ["USD"], +// primaryKey: false, +// autoIncrement: false, +// comment: null, +// field: "currencies" +// }, + +// fiat: { ??? +// type: DataTypes.BOOLEAN, +// allowNull: true, +// defaultValue: null, +// primaryKey: false, +// autoIncrement: false, +// comment: null, +// field: "fiat" +// }, + +// ** Remove - redundant / unnecessary ** +// account_id: { +// type: DataTypes.INTEGER(11), +// allowNull: true, +// defaultValue: null, +// primaryKey: false, +// autoIncrement: false, +// comment: null, +// field: "account_id" +// }, +// twofa: { = otp_secret NOT NULL +// type: DataTypes.INTEGER(1), +// allowNull: true, +// defaultValue: null, +// primaryKey: false, +// autoIncrement: false, +// comment: null, +// field: "twofa" +// }, + +// *** Move to user_keys *** + +// otpsecret: { +// type: DataTypes.STRING(255), +// allowNull: true, +// defaultValue: "CAD", +// primaryKey: false, +// autoIncrement: false, +// comment: null, +// field: "otpsecret" +// }, +// pin: { +// type: DataTypes.STRING(255), +// allowNull: true, +// defaultValue: null, +// primaryKey: false, +// autoIncrement: false, +// comment: null, +// field: "pin" +// }, +// seed: { +// type: DataTypes.STRING(255), +// allowNull: true, +// defaultValue: null, +// primaryKey: false, +// autoIncrement: false, +// comment: null, +// field: "seed" +// }, + +// ** What are these exactly ... ? ** +// ip: { ?? +// type: DataTypes.INTEGER.UNSIGNED, +// allowNull: true, +// defaultValue: null, +// primaryKey: false, +// autoIncrement: false, +// comment: null, +// field: "ip" +// }, + +// index: { +// type: DataTypes.INTEGER, +// allowNull: true, +// defaultValue: 0, +// primaryKey: false, +// autoIncrement: false, +// comment: null, +// field: "index" +// }, + +// }; + +// *** Add breakout table +// subscriptions: { +// type: DataTypes.TEXT, +// get: function() { +// return JSON.parse(this.getDataValue("subscriptions")); +// }, +// set: function(value) { +// return this.setDataValue("subscriptions", JSON.stringify(value)); +// }, +// allowNull: true, +// defaultValue: null, +// primaryKey: false, +// autoIncrement: false, +// comment: null, +// field: "subscriptions" +// }, + + // *** replaced with other field(s) *** + // locked: { - embed logic with user status (?) + // type: DataTypes.BOOLEAN, + // allowNull: true, + // defaultValue: false, + // primaryKey: false, + // autoIncrement: false, + // comment: null, + // field: "locked" + // }, + + + |
