lfra_db 1.0.4 → 1.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lfra_db",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -17,12 +17,14 @@ const visitLogSchema = new mongoose.Schema({
17
17
  },
18
18
  residentId: {
19
19
  type: mongoose.Schema.Types.ObjectId,
20
+ ref: 'Customer',
21
+ required: false
20
22
  },
21
23
  userId: {
22
- type: String,
24
+ type: mongoose.Schema.Types.ObjectId,
25
+ ref: 'User',
23
26
  required: false
24
-
25
- },
27
+ },
26
28
  qrCode: {
27
29
  type: Boolean,
28
30
  required: false
@@ -36,11 +38,11 @@ const visitLogSchema = new mongoose.Schema({
36
38
  required: false
37
39
  },
38
40
  startTime: {
39
- type: String, // Changed to Date for better handling of time
41
+ type: Date, // Changed to Date for better handling of time
40
42
  required: true
41
43
  },
42
44
  endTime: {
43
- type: Date, // Changed to Date for better handling of time
45
+ type: Date,
44
46
  required: false
45
47
  },
46
48
  days: {
@@ -63,13 +65,12 @@ const visitLogSchema = new mongoose.Schema({
63
65
  type: String,
64
66
  required: true,
65
67
  enum: ['Visit Confirmation', 'Scheduled', 'Checked In', 'Checked Out', 'Cancelled'] // Define valid statuses
66
- // Define valid statuses
67
68
  },
68
69
  vehicle: {
69
- registration: String,
70
- make: String,
71
- color: String,
72
- occupants: String,
70
+ registration: { type: String, required: false },
71
+ make: { type: String, required: false },
72
+ color: { type: String, required: false },
73
+ occupants: { type: String, required: false }
73
74
  },
74
75
  visitationCode: {
75
76
  type: Number,
@@ -77,15 +78,15 @@ const visitLogSchema = new mongoose.Schema({
77
78
  },
78
79
  requestedBy: {
79
80
  type: mongoose.Schema.Types.ObjectId,
80
- ref: "User",
81
+ ref: 'User',
81
82
  required: false
82
83
  },
83
84
  facilityId: {
84
85
  type: mongoose.Schema.Types.ObjectId,
85
86
  ref: 'Facility',
86
87
  required: true // Ensures a facilityId is always provided
87
- },
88
-
88
+ }
89
+ }, {
89
90
  timestamps: true // Automatically add createdAt and updatedAt fields
90
91
  });
91
92
 
@@ -1,6 +1,6 @@
1
1
  const mongoose = require('mongoose');
2
2
 
3
- // Define the schema for companies
3
+ // Define the schema for visitors
4
4
  const visitorSchema = new mongoose.Schema({
5
5
  firstName: {
6
6
  type: String,
@@ -26,36 +26,38 @@ const visitorSchema = new mongoose.Schema({
26
26
  type: String,
27
27
  required: false
28
28
  },
29
- status:{
30
- type:String,
31
- required:false
29
+ status: {
30
+ type: String,
31
+ required: false
32
32
  },
33
33
  type: {
34
34
  type: String,
35
- required: false,
36
- enum: ["Staff", "Other","Service Providers","Government Officials/Agents","Student",""]
35
+ enum: ["Staff", "Other", "Service Providers", "Government Officials/Agents", "Student", ""],
36
+ required: false
37
37
  },
38
38
  residentId: {
39
39
  type: mongoose.Schema.Types.ObjectId,
40
40
  ref: 'Customer',
41
+ required: false
41
42
  },
42
43
  facilityId: {
43
44
  type: mongoose.Schema.Types.ObjectId,
44
45
  ref: 'Facility',
46
+ required: false
45
47
  },
46
- invited:{
47
- type:Boolean,
48
- required:false
48
+ invited: {
49
+ type: Boolean,
50
+ required: false,
51
+ default: false
49
52
  },
50
- invitationDate:{
51
- type:String,
52
- required:false
53
+ invitationDate: {
54
+ type: Date, // Changed to Date for better handling of dates
55
+ required: false
53
56
  }
54
57
  }, {
55
58
  timestamps: true // Automatically add createdAt and updatedAt fields
56
59
  });
57
60
 
58
- // Indexes for improved performance
59
61
  // Compile the model from the schema
60
62
  const Visitor = mongoose.model('Visitor', visitorSchema);
61
63