Documentation ¶
Index ¶
- Constants
- func Close(db *DB) error
- type DB
- func (db *DB) DeleteActivities(ids []int) (n int64, err error)
- func (db *DB) DeleteActivity(id int) (n int64, err error)
- func (db *DB) GetActivities(ids []int) (activities []*activity.Activity, err error)
- func (db *DB) GetActivitiesAll() (activities []*activity.Activity, err error)
- func (db *DB) GetActivitiesAllMap() (activitiesMap map[int]*activity.Activity, err error)
- func (db *DB) GetActivity(id int) (act *activity.Activity, err error)
- func (db *DB) InsertActivities(activities []*activity.Activity, duplicateInsertPolicy DuplicateInsertPolicy) (err error)
- func (db *DB) InsertActivity(act *activity.Activity, duplicateInsertPolicy DuplicateInsertPolicy) (n int64, err error)
- func (db *DB) UpdateActivity(act *activity.Activity, id int) (n int64, err error)
- func (db *DB) UpdateCost(id int, newCost float64) (n int64, err error)
- func (db *DB) UpdateDescription(id int, newDescription string) (n int64, err error)
- func (db *DB) UpdateDuration(id int, newDuration time.Duration) (n int64, err error)
- func (db *DB) UpdateFinish(id int, newFinish time.Time) (n int64, err error)
- func (db *DB) UpdateId(oldId, newId int) (n int64, err error)
- func (db *DB) UpdatePredecessors(id int, predecessorsId []int) (n int64, err error)
- func (db *DB) UpdateStart(id int, newStart time.Time) (n int64, err error)
- func (db *DB) UpdateSuccessors(id int, successorsId []int) (n int64, err error)
- type DuplicateInsertPolicy
Constants ¶
const TableName = "activities"
TableName is the name of the table in the sqlite database.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
A DB stores a pointer to a sqlite database connection.
func New ¶
New creates a new instance of the DB type by initializing and opening a database. located at the specified 'path'. It returns a pointer to the created DB and an error, if any. The returned DB is ready for use, and the associated database file is opened. It should be noted that the DB connection should be closed after use.
func (*DB) DeleteActivities ¶ added in v0.0.7
DeleteActivities deletes the activities with the specified ids from the database. It returns the number of affected rows and an error if the deletion operation encounters any issues.
func (*DB) DeleteActivity ¶ added in v0.0.7
DeleteActivity deletes the activity with the specified id from the database. It returns the number of affected rows and an error if the deletion operation encounters any issues.
func (*DB) GetActivities ¶ added in v0.0.7
GetActivities retrieves the activities with the specified ids from the database.
func (*DB) GetActivitiesAll ¶ added in v0.0.7
GetActivitiesAll retrieves all activities from the database. It returns a slice of pointers to activities.
func (*DB) GetActivitiesAllMap ¶ added in v0.0.7
GetActivitiesAllMap retrieves all activities from the database, and returns them as a map with activity ids as keys and pointers to activities as values.
func (*DB) GetActivity ¶ added in v0.0.7
GetActivity retrieves the activity with the specified id from the database.
func (*DB) InsertActivities ¶
func (db *DB) InsertActivities(activities []*activity.Activity, duplicateInsertPolicy DuplicateInsertPolicy) (err error)
InsertActivities inserts the provided activities into the database.
func (*DB) InsertActivity ¶
func (db *DB) InsertActivity(act *activity.Activity, duplicateInsertPolicy DuplicateInsertPolicy) (n int64, err error)
InsertActivity inserts the provided activity into the database.
func (*DB) UpdateActivity ¶ added in v0.0.7
UpdateActivity updates the activity with the specified id in the database using the information provided in the activity.
func (*DB) UpdateCost ¶ added in v0.0.7
UpdateCost updates the cost of an activity with the specified id in the database
func (*DB) UpdateDescription ¶ added in v0.0.7
UpdateDescription updates the description of an activity with the specified id in the database
func (*DB) UpdateDuration ¶ added in v0.0.10
UpdateDuration updates the duration of an activity with the specified id in the database
func (*DB) UpdateFinish ¶ added in v0.0.7
UpdateFinish updates the finish time of an activity with the specified id in the database
func (*DB) UpdateId ¶ added in v0.0.7
UpdateId updates the id of an activity with the specified id in the database
func (*DB) UpdatePredecessors ¶ added in v0.0.7
UpdatePredecessors updates the predecessors of the activity with the specified id in the database.
func (*DB) UpdateStart ¶ added in v0.0.7
UpdateStart updates the start time of an activity with the specified id in the database
type DuplicateInsertPolicy ¶ added in v0.0.12
type DuplicateInsertPolicy int
DuplicateInsertPolicy defines the policy for handling duplicate inserts in a database.
const ( None DuplicateInsertPolicy = 0 // Do nothing Ignore DuplicateInsertPolicy = 1 // Ignore duplicate inserts Replace DuplicateInsertPolicy = 2 // Replace duplicate inserts )
Enumeration of available duplicate insert policies.