@dynamatix/cat-shared 0.0.122 → 0.0.123
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/models/index.js +2 -1
- package/models/property-metadata.model.js +57 -0
- package/package.json +1 -1
package/models/index.js
CHANGED
|
@@ -7,4 +7,5 @@ export { default as DocumentModel } from './document.model.js';
|
|
|
7
7
|
export { default as WorkflowAlertModel } from './workflow-alert.model.js';
|
|
8
8
|
export { default as WorkflowConfigModel } from './workflow-config.model.js';
|
|
9
9
|
export { default as DocumentHistoryModel } from './document-history.model.js';
|
|
10
|
-
export { default as MetaModel } from './meta.model.js';
|
|
10
|
+
export { default as MetaModel } from './meta.model.js';
|
|
11
|
+
export { default as PropertyMetaDataModel } from './property-metadata.model.js';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import applyAuditMiddleware from "../middlewares/audit.middleware";
|
|
3
|
+
|
|
4
|
+
const propertyMetadataSchema = new mongoose.Schema({
|
|
5
|
+
collectionName: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
index: true
|
|
9
|
+
},
|
|
10
|
+
propertyName: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true,
|
|
13
|
+
index: true
|
|
14
|
+
},
|
|
15
|
+
type: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
enum: ['String', 'Number', 'Boolean', 'Date', 'ObjectId', 'Array', 'Object', 'Mixed'],
|
|
19
|
+
index: true
|
|
20
|
+
},
|
|
21
|
+
aliasName: {
|
|
22
|
+
type: String,
|
|
23
|
+
required: false,
|
|
24
|
+
default: ""
|
|
25
|
+
},
|
|
26
|
+
referenceCollection: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: false,
|
|
29
|
+
default: null
|
|
30
|
+
},
|
|
31
|
+
// Additional recommended fields
|
|
32
|
+
description: {
|
|
33
|
+
type: String,
|
|
34
|
+
required: false,
|
|
35
|
+
default: ""
|
|
36
|
+
},
|
|
37
|
+
isRequired: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
required: true,
|
|
40
|
+
default: false,
|
|
41
|
+
index: true
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
timestamps: true
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Compound indexes for efficient querying
|
|
48
|
+
propertyMetadataSchema.index({ collectionName: 1, propertyName: 1 }, { unique: true });
|
|
49
|
+
propertyMetadataSchema.index({ collectionName: 1, isActive: 1 });
|
|
50
|
+
propertyMetadataSchema.index({ type: 1, isActive: 1 });
|
|
51
|
+
propertyMetadataSchema.index({ category: 1, isActive: 1 });
|
|
52
|
+
|
|
53
|
+
// Apply audit middleware
|
|
54
|
+
applyAuditMiddleware(propertyMetadataSchema, "PropertyMetaData");
|
|
55
|
+
|
|
56
|
+
const PropertyMetaDataModel = mongoose.models.PropertyMetaData || mongoose.model('PropertyMetaData', propertyMetadataSchema);
|
|
57
|
+
export default PropertyMetaDataModel;
|