Skip to content

Instantly share code, notes, and snippets.

@soncco
Created July 15, 2025 00:41
Show Gist options
  • Save soncco/f7689f18198a32da375de99884a23dad to your computer and use it in GitHub Desktop.
Save soncco/f7689f18198a32da375de99884a23dad to your computer and use it in GitHub Desktop.
mongo examples
// communications
{
_id: ObjectId,
type: "email" | "sms" | "push" | "chat",
direction: "outbound" | "inbound",
threadId: ObjectId,
originalNotificationId: ObjectId,
sender: {
userId: ObjectId,
email: "[email protected]",
phone: "+1234567890"
},
recipient: {
userId: ObjectId,
email: "[email protected]",
phone: "+1987654321"
},
content: {
subject: "Subject line",
text: "Plain text content",
html: "<p>HTML content</p>"
},
metadata: {
platform: "mailgun" | "plivo" | "internal",
externalId: "mg-message-id",
referenceCode: "REF123", // Para SMS
headers: {}, // Para emails
deliveryStatus: "sent" | "delivered" | "failed"
},
status: "pending" | "sent" | "delivered" | "read" | "responded",
timestamp: ISODate,
createdAt: ISODate,
updatedAt: ISODate
}
// threads
{
_id: ObjectId,
subject: "Original subject",
participants: [
{
userId: ObjectId,
email: "[email protected]",
phone: "+1234567890"
}
],
lastMessageAt: ISODate,
messageCount: 3,
status: "active" | "closed",
createdAt: ISODate
}
// notifications
{
_id: ObjectId,
userId: ObjectId,
type: "reminder" | "alert" | "update",
title: "Notification title",
content: "Notification content",
channels: ["email", "sms", "push"],
sentChannels: ["email"], // Canales ya enviados
threadId: ObjectId, // Se crea cuando se envía
status: "pending" | "sent" | "responded",
createdAt: ISODate
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment