pristine-member-nest-api-database 1.0.99 → 1.2.1
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.
- package/dist/models/User.model.js +22 -12
- package/models/User.model.ts +31 -20
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.mongoUser = void 0;
|
|
27
27
|
const mongoose_1 = __importStar(require("mongoose"));
|
|
28
|
-
mongoose_1.default.set(
|
|
28
|
+
mongoose_1.default.set("strictPopulate", false);
|
|
29
29
|
const userSchema = new mongoose_1.Schema({
|
|
30
30
|
userId: String,
|
|
31
31
|
userName: String,
|
|
@@ -33,7 +33,11 @@ const userSchema = new mongoose_1.Schema({
|
|
|
33
33
|
userType: String,
|
|
34
34
|
member: {
|
|
35
35
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
36
|
-
ref:
|
|
36
|
+
ref: "Members", // Reference to the 'Members' model
|
|
37
|
+
},
|
|
38
|
+
linkMemberUser: {
|
|
39
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
40
|
+
ref: "Users", // Reference to the 'Users' model (represents the linked member user)
|
|
37
41
|
},
|
|
38
42
|
userPassword: String,
|
|
39
43
|
unsuccessfulLoginAttempts: Number,
|
|
@@ -50,20 +54,26 @@ const userSchema = new mongoose_1.Schema({
|
|
|
50
54
|
isActive: { type: Boolean, default: true },
|
|
51
55
|
isUserCreationNotified: { type: Boolean, default: false },
|
|
52
56
|
isPasswordNotified: { type: Boolean, default: false },
|
|
53
|
-
accessibleBranches: [
|
|
57
|
+
accessibleBranches: [
|
|
58
|
+
{
|
|
54
59
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
55
|
-
ref:
|
|
56
|
-
}
|
|
60
|
+
ref: "Branches", // Reference to the 'Branches' model
|
|
61
|
+
},
|
|
62
|
+
],
|
|
57
63
|
requisitionUserType: { type: String, default: "" },
|
|
58
|
-
requisitionBranches: [
|
|
64
|
+
requisitionBranches: [
|
|
65
|
+
{
|
|
59
66
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
60
|
-
ref:
|
|
61
|
-
}
|
|
62
|
-
|
|
67
|
+
ref: "Branches", // Reference to the 'Branches' model
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
audit: [
|
|
71
|
+
{
|
|
63
72
|
userId: String,
|
|
64
73
|
auditedOn: { type: Date, default: Date.now() },
|
|
65
|
-
actionType: String
|
|
66
|
-
}
|
|
74
|
+
actionType: String,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
67
77
|
});
|
|
68
|
-
const mongoUser = mongoose_1.default.model(
|
|
78
|
+
const mongoUser = mongoose_1.default.model("Users", userSchema);
|
|
69
79
|
exports.mongoUser = mongoUser;
|
package/models/User.model.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import mongoose, { Document, Schema } from
|
|
2
|
-
import { Audit } from
|
|
1
|
+
import mongoose, { Document, Schema } from "mongoose";
|
|
2
|
+
import { Audit } from "../interface/Audit.interface";
|
|
3
3
|
|
|
4
4
|
interface UserDocument extends Document {
|
|
5
5
|
userId: string;
|
|
@@ -23,12 +23,13 @@ interface UserDocument extends Document {
|
|
|
23
23
|
accessibleBranches: mongoose.Types.ObjectId[];
|
|
24
24
|
requisitionUserType: string;
|
|
25
25
|
requisitionBranches: mongoose.Types.ObjectId[];
|
|
26
|
-
companyName:string;
|
|
27
|
-
contactNumber:string;
|
|
26
|
+
companyName: string;
|
|
27
|
+
contactNumber: string;
|
|
28
28
|
audit: Audit[];
|
|
29
|
+
linkMemberUser: mongoose.Types.ObjectId;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
mongoose.set(
|
|
32
|
+
mongoose.set("strictPopulate", false);
|
|
32
33
|
|
|
33
34
|
const userSchema = new Schema<UserDocument>({
|
|
34
35
|
userId: String,
|
|
@@ -37,7 +38,11 @@ const userSchema = new Schema<UserDocument>({
|
|
|
37
38
|
userType: String,
|
|
38
39
|
member: {
|
|
39
40
|
type: Schema.Types.ObjectId,
|
|
40
|
-
ref:
|
|
41
|
+
ref: "Members", // Reference to the 'Members' model
|
|
42
|
+
},
|
|
43
|
+
linkMemberUser: {
|
|
44
|
+
type: Schema.Types.ObjectId,
|
|
45
|
+
ref: "Users", // Reference to the 'Users' model (represents the linked member user)
|
|
41
46
|
},
|
|
42
47
|
userPassword: String,
|
|
43
48
|
unsuccessfulLoginAttempts: Number,
|
|
@@ -54,22 +59,28 @@ const userSchema = new Schema<UserDocument>({
|
|
|
54
59
|
isActive: { type: Boolean, default: true },
|
|
55
60
|
isUserCreationNotified: { type: Boolean, default: false },
|
|
56
61
|
isPasswordNotified: { type: Boolean, default: false },
|
|
57
|
-
accessibleBranches: [
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
accessibleBranches: [
|
|
63
|
+
{
|
|
64
|
+
type: Schema.Types.ObjectId,
|
|
65
|
+
ref: "Branches", // Reference to the 'Branches' model
|
|
66
|
+
},
|
|
67
|
+
],
|
|
61
68
|
requisitionUserType: { type: String, default: "" },
|
|
62
|
-
requisitionBranches: [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
requisitionBranches: [
|
|
70
|
+
{
|
|
71
|
+
type: Schema.Types.ObjectId,
|
|
72
|
+
ref: "Branches", // Reference to the 'Branches' model
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
audit: [
|
|
76
|
+
{
|
|
77
|
+
userId: String,
|
|
78
|
+
auditedOn: { type: Date, default: Date.now() },
|
|
79
|
+
actionType: String,
|
|
80
|
+
},
|
|
81
|
+
],
|
|
71
82
|
});
|
|
72
83
|
|
|
73
|
-
const mongoUser = mongoose.model<UserDocument>(
|
|
84
|
+
const mongoUser = mongoose.model<UserDocument>("Users", userSchema);
|
|
74
85
|
|
|
75
86
|
export { UserDocument, mongoUser };
|