import { Schema } from "mongoose";

//#region src/schemas/dictionary.schema.ts
const versionedContentElSchema = new Schema({
	name: { type: String },
	description: { type: String },
	content: {
		type: Schema.Types.Mixed,
		required: true
	}
}, { timestamps: true });
const dictionarySchema = new Schema({
	projectIds: {
		type: [Schema.Types.ObjectId],
		ref: "Project",
		required: true
	},
	key: {
		type: String,
		required: true
	},
	title: {
		type: String,
		default: ""
	},
	description: {
		type: String,
		default: ""
	},
	tags: {
		type: [String],
		default: []
	},
	content: {
		type: Map,
		of: versionedContentElSchema,
		required: true,
		default: null
	},
	creatorId: {
		type: Schema.Types.ObjectId,
		ref: "User",
		required: true
	}
}, {
	timestamps: true,
	toJSON: {
		virtuals: true,
		versionKey: false,
		transform(_doc, ret) {
			const { _id, ...rest } = ret;
			return {
				...rest,
				id: _id.toString()
			};
		}
	},
	toObject: {
		virtuals: true,
		transform(_doc, ret) {
			const { _id, ...rest } = ret;
			return {
				...rest,
				id: _id
			};
		}
	}
});

//#endregion
export { dictionarySchema };
//# sourceMappingURL=dictionary.schema.mjs.map