@justair/justair-library 4.7.22 → 4.7.24
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/.idea/justair-library.iml +9 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/justair-justair-library-4.7.22.tgz +0 -0
- package/package.json +1 -1
- package/src/models/events.js +9 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="JAVA_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
+
<exclude-output />
|
|
5
|
+
<content url="file://$MODULE_DIR$" />
|
|
6
|
+
<orderEntry type="inheritedJdk" />
|
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
+
</component>
|
|
9
|
+
</module>
|
package/.idea/misc.xml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
|
|
4
|
+
<output url="file://$PROJECT_DIR$/out" />
|
|
5
|
+
</component>
|
|
6
|
+
</project>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/justair-library.iml" filepath="$PROJECT_DIR$/.idea/justair-library.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
|
Binary file
|
package/package.json
CHANGED
package/src/models/events.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
1
|
+
import mongoose, {Types} from "mongoose";
|
|
2
2
|
|
|
3
3
|
// Events Audit Schema
|
|
4
4
|
const eventsAuditSchema = mongoose.Schema(
|
|
@@ -38,10 +38,11 @@ const eventsSchema = mongoose.Schema(
|
|
|
38
38
|
enum: ["Collocation", "Deployed", "Maintenance", "Pending Deployment"],
|
|
39
39
|
},
|
|
40
40
|
pausedParameters: [String],
|
|
41
|
+
originalId: { type: mongoose.Types.ObjectId },
|
|
41
42
|
},
|
|
42
43
|
{
|
|
43
44
|
timestamps: true,
|
|
44
|
-
}
|
|
45
|
+
},
|
|
45
46
|
);
|
|
46
47
|
|
|
47
48
|
// Primary lookup pattern from monitors - for $lookup operations
|
|
@@ -73,6 +74,8 @@ eventsSchema.pre("deleteMany", async function () {
|
|
|
73
74
|
console.log(`Logging ${docsToDelete.length} documents to events audit`);
|
|
74
75
|
const auditLogs = docsToDelete.map((doc) => ({
|
|
75
76
|
...doc,
|
|
77
|
+
originalId: doc._id, // store reference to original _id
|
|
78
|
+
_id: undefined, // let Mongo generate new _id
|
|
76
79
|
deletedAt: new Date(),
|
|
77
80
|
}));
|
|
78
81
|
await EventsAudit.insertMany(auditLogs);
|
|
@@ -86,6 +89,8 @@ eventsSchema.pre("deleteOne", async function () {
|
|
|
86
89
|
console.log("Logging deleteOne to events audit", docToDelete);
|
|
87
90
|
const auditLog = new EventsAudit({
|
|
88
91
|
...docToDelete,
|
|
92
|
+
originalId: docToDelete._id, // store reference to original _id
|
|
93
|
+
_id: undefined, // let Mongo generate new _id
|
|
89
94
|
deletedAt: new Date(),
|
|
90
95
|
});
|
|
91
96
|
await auditLog.save();
|
|
@@ -112,6 +117,8 @@ eventsSchema.pre("updateMany", async function () {
|
|
|
112
117
|
console.log(`Logging ${docsToUpdate.length} documents to events audit`);
|
|
113
118
|
const auditLogs = docsToUpdate.map((doc) => ({
|
|
114
119
|
...doc,
|
|
120
|
+
originalId: doc._id, // store reference to original _id
|
|
121
|
+
_id: undefined, // let Mongo generate new _id
|
|
115
122
|
deletedAt: null, // Not deleted
|
|
116
123
|
}));
|
|
117
124
|
await EventsAudit.insertMany(auditLogs);
|