summaryrefslogtreecommitdiff
path: root/src/routers/vault/types/Identity.js
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2020-03-15 21:56:57 -0400
committergumi <git@gumi.ca>2020-03-15 21:56:57 -0400
commit8a1302edf0506c92bd9a8e83ed7c1e145b246513 (patch)
treefae4703cb17a829b102c60550acb7cdea0878685 /src/routers/vault/types/Identity.js
parenta0a35766911f5354487663b0f148b824ca32ba44 (diff)
downloadapi-8a1302edf0506c92bd9a8e83ed7c1e145b246513.tar.gz
api-8a1302edf0506c92bd9a8e83ed7c1e145b246513.tar.bz2
api-8a1302edf0506c92bd9a8e83ed7c1e145b246513.tar.xz
api-8a1302edf0506c92bd9a8e83ed7c1e145b246513.zip
add an Identity type
Diffstat (limited to 'src/routers/vault/types/Identity.js')
-rw-r--r--src/routers/vault/types/Identity.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/routers/vault/types/Identity.js b/src/routers/vault/types/Identity.js
new file mode 100644
index 0000000..fb5171f
--- /dev/null
+++ b/src/routers/vault/types/Identity.js
@@ -0,0 +1,58 @@
+"use strict";
+
+const { Sequelize, Model } = require("sequelize");
+
+class Identity extends Model {
+ /**
+ * primary key
+ * @type {number}
+ */
+ //id;
+ /**
+ * the Date when the Identity was confirmed
+ * @type {Date}
+ */
+ //addedDate;
+ /**
+ * the email address of the identity
+ * @type {string}
+ */
+ //email;
+ /**
+ * the Vault user id
+ * @type {number}
+ */
+ //userId;
+
+ /**
+ * whether it is the primary identity of the vault account
+ * @virtual
+ */
+ isPrimary = false;
+
+
+ /**
+ * initialize the model (must be called prior to first use)
+ * @param {Sequelize} sequelize - the Sequelize instance
+ */
+ static define (sequelize) {
+ const {fields, options} = require("../models/vault/identity.js");
+ Identity.init(fields, { sequelize, ...options });
+
+ return Identity; // the instantiated Model
+ }
+
+ /**
+ * serialize for sending over the network
+ */
+ toJSON () {
+ return {
+ id: this.id,
+ email: this.email,
+ added: this.addedDate,
+ primary: this.isPrimary,
+ };
+ }
+}
+
+module.exports = Identity;