2024-08-03 20:54:58 +00:00
|
|
|
const mongoose = require("mongoose");
|
|
|
|
const Schema = mongoose.Schema;
|
|
|
|
|
2024-09-29 16:05:11 +00:00
|
|
|
const crypto = require("crypto");
|
|
|
|
|
2024-08-03 20:54:58 +00:00
|
|
|
const CampaignSchema = new Schema({
|
|
|
|
name: {type: String, required: true},
|
2024-09-25 23:15:53 +00:00
|
|
|
description: {type: String},
|
2024-08-08 23:29:08 +00:00
|
|
|
system: {type: String, required: true},
|
2024-08-03 20:54:58 +00:00
|
|
|
creation_date: { type: Date, default: Date.now},
|
|
|
|
last_opened: { type: Date, default: Date.now},
|
|
|
|
invite_code: { type: String, unique: true },
|
|
|
|
image: { type: String }
|
|
|
|
});
|
|
|
|
|
|
|
|
CampaignSchema.statics.generateInvite = function() {
|
2024-09-29 16:05:11 +00:00
|
|
|
return crypto.randomBytes(8).toString('base64url');
|
2024-08-03 20:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = mongoose.model('Campaign', CampaignSchema);
|