message.schema.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import mongoose from 'mongoose';
  2. const { Schema } = mongoose;
  3. const appData = {
  4. msgId: {
  5. type: String,
  6. required: true,
  7. },
  8. msgLogDateTime: {
  9. type: Date,
  10. required: true,
  11. default: () => Date.now()
  12. },
  13. msgDateTime: {
  14. type: Date,
  15. required: true,
  16. default: () => Date.now()
  17. },
  18. msgTag: [String],
  19. msgPayload: {
  20. type: String,
  21. required: true
  22. }
  23. }
  24. const messageSchema = new mongoose.Schema({
  25. appLogLocId: {
  26. type: String,
  27. ref: `appLogLoc`,
  28. required: true
  29. },
  30. appData: appData
  31. });
  32. const grpcMessageSchema = new mongoose.Schema({
  33. id: {
  34. type: String,
  35. required: true
  36. },
  37. message: messageSchema
  38. })
  39. module.exports = grpcMessageSchema
  40. // message.interface.ts
  41. // import { Document, ObjectId } from 'mongoose';
  42. // interface AppData {
  43. // msgId: string;
  44. // msgLogDateTime: Date;
  45. // msgDateTime: Date;
  46. // msgTag: string[];
  47. // msgPayload: string;
  48. // }
  49. // interface MessageDocument extends Document {
  50. // appLogLocId: string;
  51. // appData: AppData;
  52. // }
  53. // interface GrpcMessageDocument extends Document {
  54. // id: string;
  55. // message: MessageDocument;
  56. // }
  57. // export { GrpcMessageDocument, MessageDocument, AppData };