database

package
v0.0.0-...-4ba9c06 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2019 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSyntax = PostgreSQLSyntax
View Source
var MySQLSyntax = &DatabaseSyntax{
	Quote:               "`",
	Placeholder:         "?",
	UseReturningToGetID: false,
}

MySQL contains database specific options for executing queries in a MySQL database

View Source
var PostgreSQLSyntax = &DatabaseSyntax{
	Quote:               `"`,
	Placeholder:         "$1",
	UseReturningToGetID: true,
}

PostgreSQL contains database specific options for executing queries in a PostgreSQL database

View Source
var ReflectCaching = true
View Source
var SQLiteSyntax = &DatabaseSyntax{
	Quote:               `"`,
	Placeholder:         "?",
	UseReturningToGetID: false,
}

SQLite contains database specific options for executing queries in a SQLite database

Functions

func Columns

func Columns(src interface{}, includePk bool) ([]string, error)

Columns using the Default Database type.

func Delete

func Delete(db DB, table string, id int64) error

func DeleteStatement

func DeleteStatement(table string, id int64) (string, []interface{})

func Insert

func Insert(db DB, table string, src interface{}) (int64, error)

func InsertStatement

func InsertStatement(table string, src interface{}) (string, []interface{}, error)

func Update

func Update(db DB, table string, id int64, src interface{}) error

func UpdateStatement

func UpdateStatement(table string, id int64, src interface{}) (string, []interface{}, error)

Types

type CourseStore

type CourseStore struct {
	// contains filtered or unexported fields
}

func NewCourseStore

func NewCourseStore(db *sqlx.DB) *CourseStore

func (*CourseStore) Create

func (s *CourseStore) Create(p *model.Course) (*model.Course, error)

func (*CourseStore) Delete

func (s *CourseStore) Delete(courseID int64) error

func (*CourseStore) Disenroll

func (s *CourseStore) Disenroll(courseID int64, userID int64) error

func (*CourseStore) Enroll

func (s *CourseStore) Enroll(courseID int64, userID int64, role int64) error

func (*CourseStore) EnrolledUsers

func (s *CourseStore) EnrolledUsers(
	courseID int64,
	roleFilter []string,
	filterFirstName string,
	filterLastName string,
	filterEmail string,
	filterSubject string,
	filterLanguage string) ([]model.UserCourse, error)

func (*CourseStore) FindEnrolledUsers

func (s *CourseStore) FindEnrolledUsers(
	courseID int64,
	roleFilter []string,
	filterQuery string,
) ([]model.UserCourse, error)

func (*CourseStore) Get

func (s *CourseStore) Get(courseID int64) (*model.Course, error)

func (*CourseStore) GetAll

func (s *CourseStore) GetAll() ([]model.Course, error)

func (*CourseStore) GetUserEnrollment

func (s *CourseStore) GetUserEnrollment(courseID int64, userID int64) (*model.UserCourse, error)

func (*CourseStore) PointsForUser

func (s *CourseStore) PointsForUser(userID int64, courseID int64) ([]model.SheetPoints, error)

PointsForUser returns all gather points in a given course for a given user accumulated.

func (*CourseStore) RoleInCourse

func (s *CourseStore) RoleInCourse(userID int64, courseID int64) (authorize.CourseRole, error)

func (*CourseStore) Update

func (s *CourseStore) Update(p *model.Course) error

func (*CourseStore) UpdateRole

func (s *CourseStore) UpdateRole(courseID, userID int64, role int) error

type DB

type DB interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
}

type DatabaseSyntax

type DatabaseSyntax struct {
	Quote               string // the quote character for table and column names
	Placeholder         string // the placeholder style to use in generated queries
	UseReturningToGetID bool   // use PostgreSQL-style RETURNING "ID" instead of calling sql.Result.LastInsertID
}

DatabaseSyntax contains driver specific settings.

func (*DatabaseSyntax) Columns

func (d *DatabaseSyntax) Columns(src interface{}, includePk bool) ([]string, error)

Columns returns a list of column names for its input struct.

func (*DatabaseSyntax) Delete

func (d *DatabaseSyntax) Delete(db DB, table string, id int64) error

func (*DatabaseSyntax) DeleteStatement

func (d *DatabaseSyntax) DeleteStatement(table string, id int64) (string, []interface{})

func (*DatabaseSyntax) Insert

func (d *DatabaseSyntax) Insert(db DB, table string, src interface{}) (int64, error)

func (*DatabaseSyntax) InsertStatement

func (d *DatabaseSyntax) InsertStatement(table string, src interface{}) (string, []interface{}, error)

Build an sql statement to insert values returns the statement and values stmt, values, err := BuildInsertStatement(...) var newPk int64 err := db.QueryRow(stmt, values...).Scan(&newPk)

func (*DatabaseSyntax) PackStatementData

func (d *DatabaseSyntax) PackStatementData(src interface{}) ([]StatementData, error)

PackStatementData reads a struct and extract necessary data for a query. This skips the primary key "id" automatically. No data modification is made.

func (*DatabaseSyntax) Update

func (d *DatabaseSyntax) Update(db DB, table string, id int64, src interface{}) error

func (*DatabaseSyntax) UpdateStatement

func (d *DatabaseSyntax) UpdateStatement(table string, id int64, src interface{}) (string, []interface{}, error)

Build an sql statement to update values returns the statement and values stmt, values, err := BuildInsertStatement(...) var newPk int64 err := db.QueryRow(stmt, values...).Scan(&newPk)

type GradeStore

type GradeStore struct {
	// contains filtered or unexported fields
}

func NewGradeStore

func NewGradeStore(db *sqlx.DB) *GradeStore

func (*GradeStore) Create

func (s *GradeStore) Create(p *model.Grade) (*model.Grade, error)

func (*GradeStore) Get

func (s *GradeStore) Get(id int64) (*model.Grade, error)

func (*GradeStore) GetAllMissingGrades

func (s *GradeStore) GetAllMissingGrades(courseID int64, tutorID int64, groupID int64) ([]model.MissingGrade, error)

func (*GradeStore) GetFiltered

func (s *GradeStore) GetFiltered(
	courseID int64,
	sheetID int64,
	taskID int64,
	groupID int64,
	userID int64,
	tutorID int64,
	feedback string,
	acquiredPoints int,
	publicTestStatus int,
	privateTestStatus int,
	publicExecutationState int,
	privateExecutationState int,
) ([]model.Grade, error)

func (*GradeStore) GetForSubmission

func (s *GradeStore) GetForSubmission(id int64) (*model.Grade, error)

func (*GradeStore) GetOverviewGrades

func (s *GradeStore) GetOverviewGrades(courseID int64, groupID int64) ([]model.OverviewGrade, error)

func (*GradeStore) IdentifyCourseOfGrade

func (s *GradeStore) IdentifyCourseOfGrade(gradeID int64) (*model.Course, error)

func (*GradeStore) IdentifyTaskOfGrade

func (s *GradeStore) IdentifyTaskOfGrade(gradeID int64) (*model.Task, error)

func (*GradeStore) Update

func (s *GradeStore) Update(p *model.Grade) error

func (*GradeStore) UpdatePrivateTestInfo

func (s *GradeStore) UpdatePrivateTestInfo(gradeID int64, log string, status symbol.TestingResult) error

func (*GradeStore) UpdatePublicTestInfo

func (s *GradeStore) UpdatePublicTestInfo(gradeID int64, log string, status symbol.TestingResult) error

type GroupStore

type GroupStore struct {
	// contains filtered or unexported fields
}

func NewGroupStore

func NewGroupStore(db *sqlx.DB) *GroupStore

func (*GroupStore) ChangeGroupEnrollmentOfUserInCourse

func (s *GroupStore) ChangeGroupEnrollmentOfUserInCourse(p *model.GroupEnrollment) error

func (*GroupStore) Create

func (s *GroupStore) Create(p *model.Group) (*model.Group, error)

func (*GroupStore) CreateGroupEnrollmentOfUserInCourse

func (s *GroupStore) CreateGroupEnrollmentOfUserInCourse(p *model.GroupEnrollment) (*model.GroupEnrollment, error)

func (*GroupStore) Delete

func (s *GroupStore) Delete(taskID int64) error

func (*GroupStore) EnrolledUsers

func (s *GroupStore) EnrolledUsers(
	courseID int64,
	groupID int64,
	roleFilter []string,
	filterFirstName string,
	filterLastName string,
	filterEmail string,
	filterSubject string,
	filterLanguage string) ([]model.UserCourse, error)

func (*GroupStore) Get

func (s *GroupStore) Get(groupID int64) (*model.Group, error)

func (*GroupStore) GetAll

func (s *GroupStore) GetAll() ([]model.Group, error)

func (*GroupStore) GetBidOfUserForGroup

func (s *GroupStore) GetBidOfUserForGroup(userID int64, groupID int64) (bid int, err error)

func (*GroupStore) GetBidsForCourse

func (s *GroupStore) GetBidsForCourse(courseID int64) ([]model.GroupBid, error)

func (*GroupStore) GetBidsForCourseForUser

func (s *GroupStore) GetBidsForCourseForUser(courseID int64, userID int64) ([]model.GroupBid, error)

func (*GroupStore) GetGroupEnrollmentOfUserInCourse

func (s *GroupStore) GetGroupEnrollmentOfUserInCourse(userID int64, courseID int64) (*model.GroupEnrollment, error)

func (*GroupStore) GetInCourseWithUser

func (s *GroupStore) GetInCourseWithUser(userID int64, courseID int64) ([]model.GroupWithTutor, error)

func (*GroupStore) GetMembers

func (s *GroupStore) GetMembers(groupID int64) ([]model.User, error)

func (*GroupStore) GetOfTutor

func (s *GroupStore) GetOfTutor(tutorID int64, courseID int64) ([]model.GroupWithTutor, error)

func (*GroupStore) GroupsOfCourse

func (s *GroupStore) GroupsOfCourse(courseID int64) ([]model.GroupWithTutor, error)

func (*GroupStore) IdentifyCourseOfGroup

func (s *GroupStore) IdentifyCourseOfGroup(groupID int64) (*model.Course, error)

func (*GroupStore) InsertBidOfUserForGroup

func (s *GroupStore) InsertBidOfUserForGroup(userID int64, groupID int64, bid int) (int, error)

func (*GroupStore) Update

func (s *GroupStore) Update(p *model.Group) error

func (*GroupStore) UpdateBidOfUserForGroup

func (s *GroupStore) UpdateBidOfUserForGroup(userID int64, groupID int64, bid int) (int, error)

type MaterialStore

type MaterialStore struct {
	// contains filtered or unexported fields
}

func NewMaterialStore

func NewMaterialStore(db *sqlx.DB) *MaterialStore

func (*MaterialStore) Create

func (s *MaterialStore) Create(p *model.Material, courseID int64) (*model.Material, error)

func (*MaterialStore) Delete

func (s *MaterialStore) Delete(sheetID int64) error

func (*MaterialStore) Get

func (s *MaterialStore) Get(sheetID int64) (*model.Material, error)

func (*MaterialStore) GetAll

func (s *MaterialStore) GetAll() ([]model.Material, error)

func (*MaterialStore) IdentifyCourseOfMaterial

func (s *MaterialStore) IdentifyCourseOfMaterial(sheetID int64) (*model.Course, error)

func (*MaterialStore) MaterialsOfCourse

func (s *MaterialStore) MaterialsOfCourse(courseID int64, requiredRole int) ([]model.Material, error)

func (*MaterialStore) Update

func (s *MaterialStore) Update(p *model.Material) error

type SheetStore

type SheetStore struct {
	// contains filtered or unexported fields
}

func NewSheetStore

func NewSheetStore(db *sqlx.DB) *SheetStore

func (*SheetStore) Create

func (s *SheetStore) Create(p *model.Sheet, courseID int64) (*model.Sheet, error)

func (*SheetStore) Delete

func (s *SheetStore) Delete(sheetID int64) error

func (*SheetStore) Get

func (s *SheetStore) Get(sheetID int64) (*model.Sheet, error)

func (*SheetStore) GetAll

func (s *SheetStore) GetAll() ([]model.Sheet, error)

func (*SheetStore) IdentifyCourseOfSheet

func (s *SheetStore) IdentifyCourseOfSheet(sheetID int64) (*model.Course, error)

func (*SheetStore) PointsForUser

func (s *SheetStore) PointsForUser(userID int64, sheetID int64) ([]model.TaskPoints, error)

PointsForUser returns all gather points in a given sheet for a given user accumulated.

func (*SheetStore) SheetsOfCourse

func (s *SheetStore) SheetsOfCourse(courseID int64) ([]model.Sheet, error)

func (*SheetStore) Update

func (s *SheetStore) Update(p *model.Sheet) error

type StatementData

type StatementData struct {
	Column string
	Value  interface{}
}

func PackStatementData

func PackStatementData(src interface{}) ([]StatementData, error)

type SubmissionStore

type SubmissionStore struct {
	// contains filtered or unexported fields
}

func NewSubmissionStore

func NewSubmissionStore(db *sqlx.DB) *SubmissionStore

func (*SubmissionStore) Create

func (*SubmissionStore) Get

func (s *SubmissionStore) Get(submissionID int64) (*model.Submission, error)

func (*SubmissionStore) GetByUserAndTask

func (s *SubmissionStore) GetByUserAndTask(userID int64, taskID int64) (*model.Submission, error)

func (*SubmissionStore) GetFiltered

func (s *SubmissionStore) GetFiltered(filterCourseID, filterGroupID, filterUserID, filterSheetID, filterTaskID int64) ([]model.Submission, error)

type TaskStore

type TaskStore struct {
	// contains filtered or unexported fields
}

func NewTaskStore

func NewTaskStore(db *sqlx.DB) *TaskStore

func (*TaskStore) Create

func (s *TaskStore) Create(p *model.Task, sheetID int64) (*model.Task, error)

func (*TaskStore) CreateRating

func (s *TaskStore) CreateRating(p *model.TaskRating) (*model.TaskRating, error)

func (*TaskStore) Delete

func (s *TaskStore) Delete(taskID int64) error

func (*TaskStore) Get

func (s *TaskStore) Get(taskID int64) (*model.Task, error)

func (*TaskStore) GetAll

func (s *TaskStore) GetAll() ([]model.Task, error)

func (*TaskStore) GetAllMissingTasksForUser

func (s *TaskStore) GetAllMissingTasksForUser(userID int64) ([]model.MissingTask, error)

func (*TaskStore) GetAverageRating

func (s *TaskStore) GetAverageRating(taskID int64) (float32, error)

func (*TaskStore) GetRating

func (s *TaskStore) GetRating(taskRatingID int64) (*model.TaskRating, error)

func (*TaskStore) GetRatingOfTaskByUser

func (s *TaskStore) GetRatingOfTaskByUser(taskID int64, userID int64) (*model.TaskRating, error)

func (*TaskStore) IdentifyCourseOfTask

func (s *TaskStore) IdentifyCourseOfTask(taskID int64) (*model.Course, error)

func (*TaskStore) IdentifySheetOfTask

func (s *TaskStore) IdentifySheetOfTask(taskID int64) (*model.Sheet, error)

func (*TaskStore) TasksOfSheet

func (s *TaskStore) TasksOfSheet(sheetID int64) ([]model.Task, error)

func (*TaskStore) Update

func (s *TaskStore) Update(p *model.Task) error

func (*TaskStore) UpdateRating

func (s *TaskStore) UpdateRating(p *model.TaskRating) error

type UserStore

type UserStore struct {
	// contains filtered or unexported fields
}

func NewUserStore

func NewUserStore(db *sqlx.DB) *UserStore

func (*UserStore) Create

func (s *UserStore) Create(p *model.User) (*model.User, error)

func (*UserStore) Delete

func (s *UserStore) Delete(userID int64) error

func (*UserStore) Find

func (s *UserStore) Find(query string) ([]model.User, error)

func (*UserStore) FindByEmail

func (s *UserStore) FindByEmail(email string) (*model.User, error)

func (*UserStore) Get

func (s *UserStore) Get(userID int64) (*model.User, error)

func (*UserStore) GetAll

func (s *UserStore) GetAll() ([]model.User, error)

func (*UserStore) GetEnrollments

func (s *UserStore) GetEnrollments(userID int64) ([]model.Enrollment, error)

func (*UserStore) Update

func (s *UserStore) Update(p *model.User) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL