【发布时间】:2013-11-22 18:36:00
【问题描述】:
我正致力于在 Node.js 中实现通知系统,类似于 Facebook 通知系统。我见过一些使用 Socket.io 的实现,但我不知道它是否适合我的情况。我正在考虑的另一种方法是创建一个通知模型(我使用 MongoDB 作为存储),如下所示:
var Notification = new mongoose.Schema({
title: {type: String},
added: {type: Date},
accountId: {type: mongoose.Schema.ObjectId},
notificationType: {type: String},
isSeen: {type: Boolean}
});
然后,我将在我的帐户架构中使用它:
var AccountSchema = new mongoose.Schema({
email: { type: String, unique: true },
password: { type: String },
name: {
first: { type: String },
last: { type: String },
full: {type: String}
},
notifications: [Notification]
});
然后,我将根据操作向用户添加通知。但是,我不太确定这种方法是否会奏效。因此,我想知道哪种方法最适合这种情况:在线/离线通知。
提前致谢,
【问题讨论】:
标签: javascript node.js mongodb notifications