Documentation
¶
Index ¶
Constants ¶
View Source
const ( CreatedKey = "history.created" UpdatedKey = "history.updated" DeletedKey = "history.deleted" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionHistory ¶
func NewActionHistory ¶
func NewActionHistory(at time.Time) *ActionHistory
type CrudDao ¶
type CrudDao interface { // InitializeCompositeUniqueIndex will set a unique key tupling constraint to the collection. InitializeCompositeUniqueIndex(ctx context.Context, logger l.Logger, keys bson.D) l.Error // Create inserts the specified record into the database. Create(ctx context.Context, logger l.Logger, model interface{}) (modelId string, err l.Error) // CreateWithId inserts the specified record into the database with the given id. CreateWithId(ctx context.Context, logger l.Logger, id string, model interface{}) (modelId string, err l.Error) // Read retrieves the records specified by the parameters. Read(ctx context.Context, logger l.Logger, params bson.M, decodeModelCallback func(bsonBytes []byte, modelId string) (interface{}, error), opts ...*options.FindOptions) ([]CrudDaoModel, l.Error) // ReadById retrieves the record specified by the id. ReadById(ctx context.Context, logger l.Logger, id string, decodeModelCallback func(bsonBytes []byte, modelId string) (interface{}, error), opts ...*options.FindOptions) (model CrudDaoModel, found bool, err l.Error) // Update changes records based off the parameters. Update(ctx context.Context, logger l.Logger, params bson.M, model interface{}) l.Error // Update changes the record specified by the id. UpdateById(ctx context.Context, logger l.Logger, id string, model interface{}) l.Error // Delete removes one or more records from the database. Delete(ctx context.Context, logger l.Logger, params bson.M) l.Error // DeleteById removes the record matching the id. DeleteById(ctx context.Context, logger l.Logger, id string) l.Error // GetCollection returns the mongo collection being used. // Useful for database transactions not covered in the other actions of this struct. GetCollection() *mongo.Collection // GetConfiguration returns the configuration used by the dao. GetConfiguration() *CrudDaoConfig // SetRequiredParams is used to add required params for database calls. SetRequiredParams(params bson.M) }
func NewCrudDao ¶
type CrudDaoConfig ¶
type CrudDaoModel ¶
type CrudDaoModel interface { GetModel() interface{} GetHistory() *ModelHistory }
type ModelHistory ¶
type ModelHistory struct { Created *ActionHistory `bson:"created"` Updated *ActionHistory `bson:"updated"` Deleted *ActionHistory `bson:"deleted"` }
Click to show internal directories.
Click to hide internal directories.