我正在為我的網站制作推薦系統。我有兩種模式,一種是用戶,另一種是推薦。用戶模式如下:
const UserSchema = new Schema({
name: {
type: String,
required: true,
},
email: {
type: String,
required: true,
},
refId: {
type: Schema.Types.ObjectId,
ref: "referral",
},
link: {
type: String, },
createdAt: {
type: Date,
default: Date.now(),
},
})
參考架構如下:
const ReferralSchema = new Schema({
referralId: {
type: String,
unique: true
},
link: {
type: String,
unique: true
},
userId: {
type: Schema.Types.ObjectId,
ref: 'user'
},
senderMsg: {
type: String},
senderName: {
type: String},
createdAt: {
type: Date,
default: Date.now()
}
})
推薦鏈接是在注冊時創建的,之后當用戶將網站推薦給他的朋友/親戚或其他任何人時,他/她將輸入電子郵件 ID,并將帶有推薦鏈接的電子郵件發送給推薦人。現在我想跟蹤那些通過該推薦鏈接注冊的推薦的數量,并且推薦名稱應該鏈接到用戶名下。我面臨的問題是我想顯示推薦鏈接,例如: http ://example.com/invite/[email protected]
如何將此作為推薦鏈接。其次如何添加注冊用戶數并將計數保存在mongodb中。
任何幫助將不勝感激。謝謝
uj5u.com熱心網友回復:
How to make this as referral link- 當用戶參考任何其他用戶并鍵入用戶電子郵件時,您可以將該特定實體保存在資料庫中,您還可以跟蹤被推薦用戶是否從鏈接簽名。如果用戶點擊了他們的推薦鏈接,您可以設定一個標志(布林值)。
how to add the count of no of user registered and save the count- 至于計數部分,當您通過鏈接跟蹤是否有任何被推薦的用戶注冊時,您也可以獲得計數(您必須對該標志運行查詢)。
link: {
text: String,
isClicked: Boolean,
},
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/470072.html
