@churchsoln/dbms 1.0.30 → 1.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -67,6 +67,11 @@ const RELATIONSHIP = {
67
67
  OTHER: "Other",
68
68
  };
69
69
 
70
+ const CODE_LENGTH = {
71
+ OTP: 4,
72
+ ENV_NUMBER: 5,
73
+ };
74
+
70
75
  module.exports = {
71
76
  ROLES,
72
77
  TRANSFER_STATUS,
@@ -78,4 +83,5 @@ module.exports = {
78
83
  MEMBER_STATUS,
79
84
  GENDER,
80
85
  RELATIONSHIP,
86
+ CODE_LENGTH
81
87
  };
@@ -7,6 +7,7 @@ module.exports = {
7
7
  // Link to the individual profile
8
8
  memberId: {
9
9
  type: DataTypes.INTEGER,
10
+ unique: true,
10
11
  references: {
11
12
  model: "Member",
12
13
  key: "id",
@@ -121,6 +121,7 @@ module.exports = (sequelize, DataTypes) => {
121
121
  { freezeTableName: true, timestamps: false }
122
122
  );
123
123
  member.associate = function (models) {
124
+ member.hasOne(models.user, { foreignKey: "memberId", as: "user" });
124
125
  member.belongsTo(models.membership, { foreignKey: "membershipId", as: "membership" });
125
126
  member.belongsTo(models.province, { foreignKey: "provinceId", as: "province" });
126
127
  member.belongsTo(models.city, { foreignKey: "cityId", as: "city" });
@@ -52,6 +52,7 @@ module.exports = (sequelize, DataTypes) => {
52
52
  { freezeTableName: true, timestamps: false }
53
53
  );
54
54
  membership.associate = function (models) {
55
+ membership.hasMany(models.member, { foreignKey: "membershipId", as: "member" });
55
56
  membership.belongsTo(models.province, { foreignKey: "provinceId", as: "province" });
56
57
  membership.belongsTo(models.city, { foreignKey: "cityId", as: "city" });
57
58
  }
@@ -58,7 +58,6 @@ module.exports = (sequelize, DataTypes) => {
58
58
  "id",
59
59
  "memberId",
60
60
  "username",
61
- "password",
62
61
  "email",
63
62
  "roleId",
64
63
  "subRoleId",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@churchsoln/dbms",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "prestart": "node db-setup.js",
@@ -4,10 +4,11 @@ const errorCodes = require("../config/errorCodes");
4
4
  const errorMsgs = require("../config/errorMsgs");
5
5
  const { masterQueue, masterQueueEvents } = require("../queues");
6
6
  const churchManager = require("../utils/churchManager");
7
- const { QUEUES, ROLES, AUTH_DATA, SUBSCRIPTION_PLAN_ID } = require("../constants");
7
+ const { QUEUES, ROLES, AUTH_DATA, SUBSCRIPTION_PLAN_ID, CODE_LENGTH } = require("../constants");
8
8
  const bcrypt = require("bcrypt");
9
9
  const cryptr = require("../utils/crypto");
10
10
  const jwt = require("jsonwebtoken");
11
+ const utils = require("../utils");
11
12
 
12
13
  class ChurchService {
13
14
  async onboardChurch(params) {
@@ -89,7 +90,10 @@ class ChurchService {
89
90
  masterQueueEvents.on("completed", async (event) => {
90
91
  if (event.jobId === jobData.id) {
91
92
  const churchDb = await churchManager.getChurchDbConnectionById(churchData.id);
92
- const member = await churchDb.member.create({ ...churchAdminDetails })
93
+ const member = await churchDb.member.create({
94
+ ...churchAdminDetails,
95
+ envNumber: utils.generateCode(CODE_LENGTH.ENV_NUMBER)
96
+ })
93
97
  await churchDb.user.create({
94
98
  ...churchAdminDetails,
95
99
  status: true,