import mongoose from 'mongoose'; const { Schema } = mongoose; const appData = { msgId: { type: String, required: true, }, msgLogDateTime: { type: Date, required: true, default: () => Date.now() }, msgDateTime: { type: Date, required: true, default: () => Date.now() }, msgTag: [String], msgPayload: { type: String, required: true } } const messageSchema = new mongoose.Schema({ appLogLocId: { type: String, ref: `appLogLoc`, required: true }, appData: appData }); const grpcMessageSchema = new mongoose.Schema({ id: { type: String, required: true }, message: messageSchema }) module.exports = grpcMessageSchema // message.interface.ts // import { Document, ObjectId } from 'mongoose'; // interface AppData { // msgId: string; // msgLogDateTime: Date; // msgDateTime: Date; // msgTag: string[]; // msgPayload: string; // } // interface MessageDocument extends Document { // appLogLocId: string; // appData: AppData; // } // interface GrpcMessageDocument extends Document { // id: string; // message: MessageDocument; // } // export { GrpcMessageDocument, MessageDocument, AppData };