package mongo import ( "go.mongodb.org/mongo-driver/v2/bson" ) // Logger defines the interface for logging operations type Logger interface { Info(message string, fields map[string]interface{}) Error(message string, fields map[string]interface{}) Debug(message string, fields map[string]interface{}) Warn(message string, fields map[string]interface{}) } // Timestampable interface for models that support timestamps type Timestampable interface { SetCreatedAt(timestamp int64) SetUpdatedAt(timestamp int64) GetCreatedAt() int64 GetUpdatedAt() int64 } // IDGetter interface for models that can provide their ID type IDGetter interface { GetID() string } // IDSetter interface for models that can set their ID type IDSetter interface { SetID(id string) } // Model provides a common base for MongoDB documents type Model struct { ID bson.ObjectID `bson:"_id,omitempty" json:"id,omitempty"` CreatedAt int64 `bson:"created_at" json:"created_at"` UpdatedAt int64 `bson:"updated_at" json:"updated_at"` } // GetID returns the document ID func (b *Model) GetID() string { return b.ID.Hex() } // SetID sets the document ID func (b *Model) SetID(id string) { b.ID, _ = bson.ObjectIDFromHex(id) } // SetCreatedAt sets the creation timestamp func (b *Model) SetCreatedAt(timestamp int64) { b.CreatedAt = timestamp } // SetUpdatedAt sets the update timestamp func (b *Model) SetUpdatedAt(timestamp int64) { b.UpdatedAt = timestamp } // GetCreatedAt returns the creation timestamp func (b *Model) GetCreatedAt() int64 { return b.CreatedAt } // GetUpdatedAt returns the update timestamp func (b *Model) GetUpdatedAt() int64 { return b.UpdatedAt }