Capstone/ui/db/models/youtube.go

38 lines
904 B
Go
Raw Normal View History

2023-11-16 20:15:44 -05:00
package models
import (
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
"google.golang.org/api/youtube/v3"
)
const YOUTUBE_BROADCAST_TYPE = "youtube_broadcast"
type YoutubeBroadcast struct {
*CommonFields `bson:"obj_info"`
Id primitive.ObjectID `bson:"_id,omitempty"`
UserId primitive.ObjectID `bson:"user_id,omitempty"`
CorrelationId string `bson:"correlation_id,omitempty"`
2023-11-16 20:15:44 -05:00
Details *youtube.LiveBroadcast `bson:"details,omitempty"`
}
func (obj *YoutubeBroadcast) MongoId() primitive.ObjectID {
if obj.Id.IsZero() {
now := time.Now()
obj.Id = primitive.NewObjectIDFromTimestamp(now)
}
return obj.Id
}
func (obj *YoutubeBroadcast) UpdateObjectInfo() {
now := time.Now()
if obj.CommonFields == nil {
obj.CommonFields = new(CommonFields)
obj.EntityType = YOUTUBE_BROADCAST_TYPE
obj.CreatedAt = now
}
obj.UpdatedAt = now
}