Updated the MetaData.ts model

This commit is contained in:
Mathias Wagner 2023-08-03 12:16:38 +02:00
parent a43f407393
commit d9fd88ad23
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -1,8 +1,15 @@
import { model, Schema } from "mongoose";
import { fieldEncryption } from "mongoose-field-encryption";
export enum ILicenseMetaType {
TEXT = "TEXT",
NUMBER = "NUMBER",
BOOLEAN = "BOOLEAN"
}
export interface IMetaData {
projectId: string,
type: string,
type: ILicenseMetaType,
name: string,
description?: string,
defaultValue?: string,
@ -22,7 +29,10 @@ const MetaDataSchema = new Schema<IMetaData>({
type: String,
required: true
},
description: String,
description: {
type: String,
required: true
},
defaultValue: String,
public: {
type: Boolean,
@ -30,4 +40,10 @@ const MetaDataSchema = new Schema<IMetaData>({
}
});
export const MetaData = model<IMetaData>("MetaData", MetaDataSchema);
MetaDataSchema.plugin(fieldEncryption, {
fields: ["projectId", "type", "name", "description", "defaultValue", "public"],
secret: process.env.ENC_KEY,
saltGenerator: () => process.env.SIG_KEY,
});
export const MetaData = model<IMetaData>("meta", MetaDataSchema);