Initial commit
This commit is contained in:
54
models/ExploreInteractionModel.js
Normal file
54
models/ExploreInteractionModel.js
Normal file
@@ -0,0 +1,54 @@
|
||||
const mongoose = require('mongoose')
|
||||
const timestamp = require('mongoose-timestamp')
|
||||
|
||||
const exploreInteractionSchema = new mongoose.Schema({
|
||||
viewerId: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'User',
|
||||
required: true,
|
||||
index: true
|
||||
},
|
||||
targetType: {
|
||||
type: String,
|
||||
enum: ['post', 'profile', 'academy'],
|
||||
required: true
|
||||
},
|
||||
targetId: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
required: true
|
||||
},
|
||||
authorId: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'User',
|
||||
default: null
|
||||
},
|
||||
contentType: {
|
||||
type: String,
|
||||
enum: ['image', 'video', 'academy'],
|
||||
default: 'image'
|
||||
},
|
||||
action: {
|
||||
type: String,
|
||||
enum: [
|
||||
'view',
|
||||
'profile_visit',
|
||||
'share',
|
||||
'like',
|
||||
'comment',
|
||||
'offer',
|
||||
'watch_complete',
|
||||
'skip',
|
||||
'dwell'
|
||||
],
|
||||
default: 'view'
|
||||
},
|
||||
dwellMs: {
|
||||
type: Number,
|
||||
default: null
|
||||
}
|
||||
})
|
||||
|
||||
exploreInteractionSchema.index({ viewerId: 1, createdAt: -1 })
|
||||
exploreInteractionSchema.plugin(timestamp)
|
||||
|
||||
module.exports = mongoose.model('ExploreInteraction', exploreInteractionSchema)
|
||||
41
models/StoryModel.js
Normal file
41
models/StoryModel.js
Normal file
@@ -0,0 +1,41 @@
|
||||
const mongoose = require('mongoose')
|
||||
const timestamp = require('mongoose-timestamp')
|
||||
|
||||
const storySchema = new mongoose.Schema({
|
||||
user_id: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'User',
|
||||
required: true,
|
||||
index: true
|
||||
},
|
||||
media_path: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
media_type: {
|
||||
type: String,
|
||||
enum: ['image', 'video'],
|
||||
required: true
|
||||
},
|
||||
expires_at: {
|
||||
type: Date,
|
||||
required: true,
|
||||
index: true
|
||||
},
|
||||
viewers: [{
|
||||
user_id: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'User'
|
||||
},
|
||||
viewed_at: {
|
||||
type: Date,
|
||||
default: Date.now
|
||||
}
|
||||
}]
|
||||
})
|
||||
|
||||
storySchema.index({ expires_at: 1 }, { expireAfterSeconds: 0 })
|
||||
|
||||
storySchema.plugin(timestamp)
|
||||
|
||||
module.exports = mongoose.model('Story', storySchema)
|
||||
Reference in New Issue
Block a user