data

package
v0.0.0-...-9a81921 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActivityEvent  = "ActivityEvent"
	CourseEvent    = "CourseEvent"
	LessonEvent    = "LessonEvent"
	PublicEvent    = "PublicEvent"
	UserAssetEvent = "UserAssetEvent"
	StudyEvent     = "StudyEvent"
)
View Source
const (
	ActivityCreated = "created"

	CourseCreated   = "created"
	CourseAppled    = "appled"
	CourseUnappled  = "unappled"
	CoursePublished = "published"

	LessonAddedToCourse     = "added_to_course"
	LessonCreated           = "created"
	LessonCommented         = "commented"
	LessonLabeled           = "labeled"
	LessonMentioned         = "mentioned"
	LessonPublished         = "published"
	LessonReferenced        = "referenced"
	LessonRemovedFromCourse = "removed_from_course"
	LessonRenamed           = "renamed"
	LessonUnlabeled         = "unlabeled"

	StudyCreated  = "created"
	StudyAppled   = "appled"
	StudyUnappled = "unappled"

	UserAssetAddedToActivity     = "added_to_activity"
	UserAssetCommented           = "commented"
	UserAssetCreated             = "created"
	UserAssetLabeled             = "labeled"
	UserAssetMentioned           = "mentioned"
	UserAssetReferenced          = "referenced"
	UserAssetRemovedFromActivity = "removed_from_activity"
	UserAssetRenamed             = "renamed"
	UserAssetUnlabeled           = "unlabeled"
)
View Source
const (
	AuthorReason  = "author"
	CommentReason = "comment"
	ManualReason  = "manual"
	MentionReason = "mention"
)
View Source
const (
	AdminRole  = "ADMIN"
	MemberRole = "MEMBER"
	OwnerRole  = "OWNER"
	UserRole   = "USER"
)

Variables

View Source
var ErrEmailUnavailable = DataEndUserError{UniqueViolation, "email unavailable"}
View Source
var ErrEmptyPageOptions = errors.New("`po` (*PageOptions) must not be nil")
View Source
var ErrNotFound = errors.New("not found")
View Source
var ErrStudyCourseNameUnavailable = DataEndUserError{UniqueViolation, "study course name unavailable"}
View Source
var ErrStudyLabelNameUnavailable = DataEndUserError{UniqueViolation, "study label name unavailable"}
View Source
var ErrStudyUserAssetNameUnavailable = DataEndUserError{UniqueViolation, "study asset name unavailable"}
View Source
var ErrUserEmailTypeUnavailable = DataEndUserError{UniqueViolation, "user may only have one 'primary' and one 'backup' email"}
View Source
var ErrUserLoginUnavailable = DataEndUserError{UniqueViolation, "user login unavailable"}
View Source
var ErrUserStudyNameUnavailable = DataEndUserError{UniqueViolation, "user study name unavailable"}

Functions

func BatchCreateNotification

func BatchCreateNotification(
	db Queryer,
	src *Notification,
	enrolleds []*Enrolled,
) error

func CommitTransaction

func CommitTransaction(db Queryer) error

func ConnectRolePermissions

func ConnectRolePermissions(
	db Queryer,
	o *mytype.Operation,
	fields,
	roles []string,
) error

func CountActivityAssetByActivity

func CountActivityAssetByActivity(
	db Queryer,
	activityID string,
) (int32, error)

func CountActivityByLesson

func CountActivityByLesson(
	db Queryer,
	lessonID string,
	filters *ActivityFilterOptions,
) (int32, error)

func CountActivityBySearch

func CountActivityBySearch(
	db Queryer,
	filters *ActivityFilterOptions,
) (int32, error)

func CountActivityByStudy

func CountActivityByStudy(
	db Queryer,
	studyID string,
	filters *ActivityFilterOptions,
) (int32, error)

func CountActivityByUser

func CountActivityByUser(
	db Queryer,
	userID string,
	filters *ActivityFilterOptions,
) (int32, error)

func CountAppledByAppleable

func CountAppledByAppleable(db Queryer, appleableID string) (int32, error)

func CountAppledByUser

func CountAppledByUser(db Queryer, userID string) (int32, error)

func CountCommentByCommentable

func CountCommentByCommentable(
	db Queryer,
	commentableID string,
	filters *CommentFilterOptions,
) (int32, error)

CountCommentByCommentable - count comments by commentable id

func CountCommentByLabel

func CountCommentByLabel(
	db Queryer,
	labelID string,
	filters *CommentFilterOptions,
) (int32, error)

func CountCommentByStudy

func CountCommentByStudy(
	db Queryer,
	studyID string,
	filters *CommentFilterOptions,
) (int32, error)

CountCommentByStudy - count comments by study id

func CountCommentByUser

func CountCommentByUser(
	db Queryer,
	userID string,
	filters *CommentFilterOptions,
) (int32, error)

CountCommentByUser - count comments by user id

func CountCourseByApplee

func CountCourseByApplee(
	db Queryer,
	appleeID string,
	filters *CourseFilterOptions,
) (int32, error)

func CountCourseBySearch

func CountCourseBySearch(
	db Queryer,
	filters *CourseFilterOptions,
) (int32, error)

func CountCourseByStudy

func CountCourseByStudy(
	db Queryer,
	studyID string,
	filters *CourseFilterOptions,
) (int32, error)

func CountCourseByTopic

func CountCourseByTopic(
	db Queryer,
	topicID string,
	filters *CourseFilterOptions,
) (int32, error)

func CountCourseByUser

func CountCourseByUser(
	db Queryer,
	userID string,
	filters *CourseFilterOptions,
) (int32, error)

func CountCourseLessonByCourse

func CountCourseLessonByCourse(
	db Queryer,
	courseID string,
) (int32, error)

func CountEmailByUser

func CountEmailByUser(
	db Queryer,
	userID string,
	filters *EmailFilterOptions,
) (int32, error)

func CountEnrolledByEnrollable

func CountEnrolledByEnrollable(
	db Queryer,
	enrollableID string,
	filters *EnrolledFilterOptions,
) (int32, error)

func CountEnrolledByUser

func CountEnrolledByUser(
	db Queryer,
	userID string,
	filters *EnrolledFilterOptions,
) (int32, error)

func CountEventByLesson

func CountEventByLesson(
	db Queryer,
	lessonID string,
	filters *EventFilterOptions,
) (int32, error)

func CountEventByStudy

func CountEventByStudy(
	db Queryer,
	studyID string,
	filters *EventFilterOptions,
) (int32, error)

func CountEventByUser

func CountEventByUser(
	db Queryer,
	userID string,
	filters *EventFilterOptions,
) (int32, error)

func CountEventByUserAsset

func CountEventByUserAsset(
	db Queryer,
	assetID string,
	filters *EventFilterOptions,
) (int32, error)

func CountLabelByLabelable

func CountLabelByLabelable(
	db Queryer,
	labelableID string,
	filters *LabelFilterOptions,
) (int32, error)

func CountLabelBySearch

func CountLabelBySearch(
	db Queryer,
	filters *LabelFilterOptions,
) (int32, error)

func CountLabelByStudy

func CountLabelByStudy(
	db Queryer,
	studyID string,
	filters *LabelFilterOptions,
) (int32, error)

func CountLabeledByLabel

func CountLabeledByLabel(
	db Queryer,
	labelID string,
) (int32, error)

func CountLabeledByLabelable

func CountLabeledByLabelable(
	db Queryer,
	labelableID string,
) (int32, error)

func CountLessonByCourse

func CountLessonByCourse(
	db Queryer,
	courseID string,
	filters *LessonFilterOptions,
) (int32, error)

func CountLessonByEnrollee

func CountLessonByEnrollee(
	db Queryer,
	enrolleeID string,
	filters *LessonFilterOptions,
) (int32, error)

func CountLessonByLabel

func CountLessonByLabel(
	db Queryer,
	labelID string,
	filters *LessonFilterOptions,
) (int32, error)

func CountLessonBySearch

func CountLessonBySearch(
	db Queryer,
	filters *LessonFilterOptions,
) (int32, error)

func CountLessonByStudy

func CountLessonByStudy(
	db Queryer,
	studyID string,
	filters *LessonFilterOptions,
) (int32, error)

func CountLessonByUser

func CountLessonByUser(
	db Queryer,
	userID string,
	filters *LessonFilterOptions,
) (int32, error)

func CountNotificationByStudy

func CountNotificationByStudy(
	db Queryer,
	studyID string,
) (int32, error)

func CountNotificationByUser

func CountNotificationByUser(
	db Queryer,
	userID string,
) (int32, error)

func CountPermissionByType

func CountPermissionByType(
	db Queryer,
	nodeType interface{},
) (int32, error)

func CountReceivedEventByUser

func CountReceivedEventByUser(
	db Queryer,
	userID string,
	filters *EventFilterOptions,
) (int32, error)

func CountSQL

func CountSQL(
	from string,
	where WhereFrom,
	filters FilterOptions,
	args *pgx.QueryArgs,
) string

func CountStudyByApplee

func CountStudyByApplee(
	db Queryer,
	appleeID string,
	filters *StudyFilterOptions,
) (int32, error)

func CountStudyByEnrollee

func CountStudyByEnrollee(
	db Queryer,
	enrolleeID string,
	filters *StudyFilterOptions,
) (int32, error)

func CountStudyBySearch

func CountStudyBySearch(
	db Queryer,
	filters *StudyFilterOptions,
) (int32, error)

func CountStudyByTopic

func CountStudyByTopic(
	db Queryer,
	topicID string,
	filters *StudyFilterOptions,
) (int32, error)

func CountStudyByUser

func CountStudyByUser(
	db Queryer,
	userID string,
	filters *StudyFilterOptions,
) (int32, error)

func CountTopicBySearch

func CountTopicBySearch(
	db Queryer,
	filters *TopicFilterOptions,
) (int32, error)

func CountTopicByTopicable

func CountTopicByTopicable(
	db Queryer,
	topicableID string,
	filters *TopicFilterOptions,
) (int32, error)

func CountTopicedByTopic

func CountTopicedByTopic(
	db Queryer,
	topicID string,
) (int32, error)

func CountTopicedByTopicable

func CountTopicedByTopicable(
	db Queryer,
	topicableID string,
) (int32, error)

func CountUserAssetByActivity

func CountUserAssetByActivity(
	db Queryer,
	activityID string,
	filters *UserAssetFilterOptions,
) (int32, error)

func CountUserAssetByLabel

func CountUserAssetByLabel(
	db Queryer,
	labelID string,
	filters *UserAssetFilterOptions,
) (int32, error)

func CountUserAssetBySearch

func CountUserAssetBySearch(
	db Queryer,
	filters *UserAssetFilterOptions,
) (int32, error)

func CountUserAssetByStudy

func CountUserAssetByStudy(
	db Queryer,
	studyID string,
	filters *UserAssetFilterOptions,
) (int32, error)

func CountUserAssetByUser

func CountUserAssetByUser(
	db Queryer,
	userID string,
	filters *UserAssetFilterOptions,
) (int32, error)

func CountUserByAppleable

func CountUserByAppleable(
	db Queryer,
	appleableID string,
	filters *UserFilterOptions,
) (int32, error)

func CountUserByEnrollable

func CountUserByEnrollable(
	db Queryer,
	enrollableID string,
	filters *UserFilterOptions,
) (int32, error)

func CountUserByEnrollee

func CountUserByEnrollee(
	db Queryer,
	enrolleeID string,
	filters *UserFilterOptions,
) (int32, error)

func CountUserBySearch

func CountUserBySearch(
	db Queryer,
	filters *UserFilterOptions,
) (int32, error)

func CreateNotificationsFromEvent

func CreateNotificationsFromEvent(
	db Queryer,
	event *Event,
) error

func CreatePermissionSuite

func CreatePermissionSuite(
	db Queryer,
	model interface{},
) error

Creates a suite of permissions for the passed model.

  • permissions for Create/Read/Update access for each field in model.
  • permissions for Connect/Disconnect/Delete.

Defaults audience to "AUTHENTICATED"

func DecodeCursor

func DecodeCursor(cursor string) (string, error)

func DeleteActivity

func DeleteActivity(
	db Queryer,
	id string,
) error

func DeleteActivityAsset

func DeleteActivityAsset(
	db Queryer,
	assetID string,
) error

func DeleteAppled

func DeleteAppled(db Queryer, id int32) error

func DeleteAppledByAppleableAndUser

func DeleteAppledByAppleableAndUser(
	db Queryer,
	appleableID,
	userID string,
) error

func DeleteAsset

func DeleteAsset(
	db Queryer,
	id int64,
) error

func DeleteComment

func DeleteComment(
	db Queryer,
	id string,
) error

DeleteComment - delete comment with passed id

func DeleteCourse

func DeleteCourse(
	db Queryer,
	id string,
) error

func DeleteCourseLesson

func DeleteCourseLesson(
	db Queryer,
	lessonID string,
) error

func DeleteEVT

func DeleteEVT(
	db Queryer,
	emailID,
	token string,
) error

func DeleteEmail

func DeleteEmail(db Queryer, id string) error

func DeleteEnrolled

func DeleteEnrolled(
	db Queryer,
	id int32,
) error

func DeleteEnrolledByEnrollableAndUser

func DeleteEnrolledByEnrollableAndUser(
	db Queryer,
	enrollableID,
	userID string,
) error

func DeleteEvent

func DeleteEvent(
	db Queryer,
	id string,
) error

func DeleteLabel

func DeleteLabel(
	db Queryer,
	id string,
) error

func DeleteLabeled

func DeleteLabeled(
	db Queryer,
	id int32,
) error

func DeleteLabeledByLabelableAndLabel

func DeleteLabeledByLabelableAndLabel(
	db Queryer,
	labelableID,
	labelID string,
) error

func DeleteLesson

func DeleteLesson(
	db Queryer,
	id string,
) error

func DeleteNotification

func DeleteNotification(
	db Queryer,
	id string,
) error

func DeleteNotificationByStudy

func DeleteNotificationByStudy(
	db Queryer,
	userID,
	studyID string,
) error

func DeleteNotificationByUser

func DeleteNotificationByUser(
	db Queryer,
	userID string,
) error

func DeletePRT

func DeletePRT(
	db Queryer,
	userID,
	token string,
) error

func DeletePermissionSuite

func DeletePermissionSuite(
	db Queryer,
	model interface{},
) error

func DeleteStudy

func DeleteStudy(
	db Queryer,
	id string,
) error

func DeleteTopiced

func DeleteTopiced(
	db Queryer,
	id int32,
) error

func DeleteTopicedByTopicableAndTopic

func DeleteTopicedByTopicableAndTopic(
	db Queryer,
	topicableID,
	topicID string,
) error

func DeleteUser

func DeleteUser(
	db Queryer,
	id string,
) error

func DeleteUserAsset

func DeleteUserAsset(
	db Queryer,
	id string,
) error

func EncodeCursor

func EncodeCursor(value interface{}) (string, error)

func ExistsLesson

func ExistsLesson(
	db Queryer,
	id string,
) (bool, error)

func ExistsLessonByNumber

func ExistsLessonByNumber(
	db Queryer,
	studyID string,
	number int32,
) (bool, error)

func ExistsLessonByOwnerStudyAndNumber

func ExistsLessonByOwnerStudyAndNumber(
	db Queryer,
	ownerLogin,
	studyName string,
	number int32,
) (bool, error)

func ExistsUser

func ExistsUser(
	db Queryer,
	id string,
) (bool, error)

func ExistsUserByLogin

func ExistsUserByLogin(
	db Queryer,
	login string,
) (bool, error)

func GetNamesByTopicable

func GetNamesByTopicable(
	db Queryer,
	topicableID string,
) ([]string, error)

func GrantUserRoles

func GrantUserRoles(
	db Queryer,
	userID string,
	roles ...string,
) error

func Initialize

func Initialize(db Queryer) error

func IsCoursePublishable

func IsCoursePublishable(
	db Queryer,
	id string,
) (bool, error)

func ParseConstraintName

func ParseConstraintName(constraintName string) (field string)

func ReorderQuery

func ReorderQuery(po *PageOptions, query string) string

Then, we can reorder the items to the originally requested direction.

func RestoreCommentDraftFromBackup

func RestoreCommentDraftFromBackup(
	db Queryer,
	commentID string,
	backupID int32,
) error

func RestoreLessonDraftFromBackup

func RestoreLessonDraftFromBackup(
	db Queryer,
	lessonID string,
	backupID int32,
) error

func RollbackTransaction

func RollbackTransaction(db Queryer) error

func SQL3

func SQL3(
	selects []string,
	from string,
	where WhereFrom,
	filters FilterOptions,
	args *pgx.QueryArgs,
	po *PageOptions,
) string

func SearchSQL2

func SearchSQL2(
	selects []string,
	from string,
	query string,
	args *pgx.QueryArgs,
	po *PageOptions,
) string

func ToLikeAnyPatternQuery

func ToLikeAnyPatternQuery(query string) *pgtype.TextArray

func ToPrefixTsQuery

func ToPrefixTsQuery(query string) string

func ToSubQuery

func ToSubQuery(query string) string

func ToTsQuery

func ToTsQuery(query string) string

func UpdatePermission

func UpdatePermission(
	db Queryer,
	id string,
	a mytype.Audience,
) error

func UpdatePermissionAudience

func UpdatePermissionAudience(
	db Queryer,
	o *mytype.Operation,
	a mytype.Audience,
	fields []string,
) error

Types

type Activity

type Activity struct {
	AdvancedAt  pgtype.Timestamptz `db:"advanced_at" permit:"read"`
	CreatedAt   pgtype.Timestamptz `db:"created_at" permit:"read"`
	Description pgtype.Text        `db:"description" permit:"create/read/update"`
	ID          mytype.OID         `db:"id" permit:"read"`
	LessonID    mytype.OID         `db:"lesson_id" permit:"create/read/update"`
	Name        pgtype.Text        `db:"name" permit:"create/read"`
	Number      pgtype.Int4        `db:"number" permit:"read/update"`
	StudyID     mytype.OID         `db:"study_id" permit:"create/read"`
	UpdatedAt   pgtype.Timestamptz `db:"updated_at" permit:"read"`
	UserID      mytype.OID         `db:"user_id" permit:"create/read"`
}

func CreateActivity

func CreateActivity(
	db Queryer,
	row *Activity,
) (*Activity, error)

func GetActivity

func GetActivity(
	db Queryer,
	id string,
) (*Activity, error)

func GetActivityByLesson

func GetActivityByLesson(
	db Queryer,
	lessonID string,
	po *PageOptions,
	filters *ActivityFilterOptions,
) ([]*Activity, error)

func GetActivityByName

func GetActivityByName(
	db Queryer,
	studyID,
	name string,
) (*Activity, error)

func GetActivityByNumber

func GetActivityByNumber(
	db Queryer,
	studyID string,
	number int32,
) (*Activity, error)

func GetActivityByStudy

func GetActivityByStudy(
	db Queryer,
	studyID string,
	po *PageOptions,
	filters *ActivityFilterOptions,
) ([]*Activity, error)

func GetActivityByStudyAndName

func GetActivityByStudyAndName(
	db Queryer,
	study,
	name string,
) (*Activity, error)

func GetActivityByUser

func GetActivityByUser(
	db Queryer,
	userID string,
	po *PageOptions,
	filters *ActivityFilterOptions,
) ([]*Activity, error)

func SearchActivity

func SearchActivity(
	db Queryer,
	po *PageOptions,
	filters *ActivityFilterOptions,
) ([]*Activity, error)

func UpdateActivity

func UpdateActivity(
	db Queryer,
	row *Activity,
) (*Activity, error)

type ActivityAsset

type ActivityAsset struct {
	ActivityID mytype.OID         `db:"activity_id" permit:"read"`
	AssetID    mytype.OID         `db:"asset_id" permit:"read"`
	CreatedAt  pgtype.Timestamptz `db:"created_at" permit:"read"`
	Number     pgtype.Int4        `db:"number" permit:"read/update"`
}

func CreateActivityAsset

func CreateActivityAsset(
	db Queryer,
	row ActivityAsset,
) (*ActivityAsset, error)

func GetActivityAsset

func GetActivityAsset(
	db Queryer,
	assetID string,
) (*ActivityAsset, error)

func GetActivityAssetByActivity

func GetActivityAssetByActivity(
	db Queryer,
	activityID string,
	po *PageOptions,
) ([]*ActivityAsset, error)

func GetActivityAssetByActivityAndNumber

func GetActivityAssetByActivityAndNumber(
	db Queryer,
	activityID string,
	number int32,
) (*ActivityAsset, error)

func MoveActivityAsset

func MoveActivityAsset(
	db Queryer,
	activityID,
	assetID,
	afterAssetID string,
) (*ActivityAsset, error)

type ActivityEventPayload

type ActivityEventPayload struct {
	Action     string     `json:"action,omitempty"`
	ActivityID mytype.OID `json:"activity_id,omitempty"`
}

func NewActivityCreatedPayload

func NewActivityCreatedPayload(activityID *mytype.OID) (*ActivityEventPayload, error)

type ActivityFilterOptions

type ActivityFilterOptions struct {
	Search *string
}

func (*ActivityFilterOptions) SQL

func (src *ActivityFilterOptions) SQL(from string, args *pgx.QueryArgs) *SQLParts

type Appled

type Appled struct {
	AppleableID mytype.OID         `db:"appleable_id" permit:"read"`
	CreatedAt   pgtype.Timestamptz `db:"created_at" permit:"read"`
	ID          pgtype.Int4        `db:"id" permit:"read"`
	Type        pgtype.Text        `db:"type" permit:"read"`
	UserID      mytype.OID         `db:"user_id" permit:"read"`
}

func CreateAppled

func CreateAppled(
	db Queryer,
	row Appled,
) (*Appled, error)

func GetAppled

func GetAppled(db Queryer, id int32) (*Appled, error)

func GetAppledByAppleable

func GetAppledByAppleable(
	db Queryer,
	appleableID string,
	po *PageOptions,
) ([]*Appled, error)

func GetAppledByAppleableAndUser

func GetAppledByAppleableAndUser(
	db Queryer,
	appleableID,
	userID string,
) (*Appled, error)

func GetAppledByUser

func GetAppledByUser(
	db Queryer,
	userID string,
	po *PageOptions,
) ([]*Appled, error)

type Asset

type Asset struct {
	CreatedAt pgtype.Timestamptz `db:"created_at" permit:"read"`
	ID        pgtype.Int8        `db:"id" permit:"read"`
	Key       pgtype.Text        `db:"key" permit:"read"`
	Name      pgtype.Text        `db:"name" permit:"create/read/update"`
	Size      pgtype.Int8        `db:"size" permit:"create/read"`
	Subtype   pgtype.Text        `db:"subtype" permit:"create/read"`
	Type      pgtype.Text        `db:"type" permit:"create/read"`
	UserID    mytype.OID         `db:"user_id" permit:"create/read"`
}

func CreateAsset

func CreateAsset(
	db Queryer,
	row *Asset,
) (*Asset, error)

func GetAsset

func GetAsset(
	db Queryer,
	id int64,
) (*Asset, error)

func GetAssetByKey

func GetAssetByKey(
	db Queryer,
	key string,
) (*Asset, error)

func NewAssetFromFile

func NewAssetFromFile(
	userID *mytype.OID,
	storageKey string,
	file multipart.File,
	name,
	contentType string,
	size int64,
) (*Asset, error)

type Comment

type Comment struct {
	Body          mytype.Markdown    `db:"body" permit:"create/read/update"`
	CommentableID mytype.OID         `db:"commentable_id" permit:"create/read"`
	CreatedAt     pgtype.Timestamptz `db:"created_at" permit:"read"`
	Draft         pgtype.Text        `db:"draft" permit:"read/update"`
	ID            mytype.OID         `db:"id" permit:"read"`
	LabeledAt     pgtype.Timestamptz `db:"labeled_at" permit:"read"`
	LastEditedAt  pgtype.Timestamptz `db:"last_edited_at" permit:"read"`
	PublishedAt   pgtype.Timestamptz `db:"published_at" permit:"read/update"`
	StudyID       mytype.OID         `db:"study_id" permit:"create/read"`
	Type          pgtype.Text        `db:"type" permit:"create/read"`
	UpdatedAt     pgtype.Timestamptz `db:"updated_at" permit:"read"`
	UserID        mytype.OID         `db:"user_id" permit:"create/read"`
}

Comment - data type comment

func BatchGetComment

func BatchGetComment(
	db Queryer,
	ids []string,
) ([]*Comment, error)

BatchGetComment - get all comments ids included in the ids param

func CreateComment

func CreateComment(
	db Queryer,
	row *Comment,
) (*Comment, error)

CreateComment - create a comment

func GetComment

func GetComment(
	db Queryer,
	id string,
) (*Comment, error)

GetComment - get comment by id

func GetCommentByCommentable

func GetCommentByCommentable(
	db Queryer,
	commentableID string,
	po *PageOptions,
	filters *CommentFilterOptions,
) ([]*Comment, error)

GetCommentByCommentable - get comments by commentable id

func GetCommentByLabel

func GetCommentByLabel(
	db Queryer,
	labelID string,
	po *PageOptions,
	filters *CommentFilterOptions,
) ([]*Comment, error)

func GetCommentByStudy

func GetCommentByStudy(
	db Queryer,
	studyID string,
	po *PageOptions,
	filters *CommentFilterOptions,
) ([]*Comment, error)

GetCommentByStudy - get comments by study id

func GetCommentByUser

func GetCommentByUser(
	db Queryer,
	userID string,
	po *PageOptions,
	filters *CommentFilterOptions,
) ([]*Comment, error)

GetCommentByUser - get comments by user id

func GetUserNewComment

func GetUserNewComment(
	db Queryer,
	userID,
	commentableID string,
) (*Comment, error)

GetUserNewComment - get user's current comment draft

func UpdateComment

func UpdateComment(
	db Queryer,
	row *Comment,
) (*Comment, error)

UpdateComment - Update comment

type CommentDraftBackup

type CommentDraftBackup struct {
	CommentID mytype.OID         `db:"comment_id" permit:"read"`
	CreatedAt pgtype.Timestamptz `db:"created_at" permit:"read"`
	Draft     pgtype.Text        `db:"draft" permit:"read"`
	ID        pgtype.Int4        `db:"id" permit:"read"`
	UpdatedAt pgtype.Timestamptz `db:"updated_at" permit:"read"`
}

func GetCommentDraftBackup

func GetCommentDraftBackup(
	db Queryer,
	commentID string,
	id int32,
) (*CommentDraftBackup, error)

func GetCommentDraftBackupByComment

func GetCommentDraftBackupByComment(
	db Queryer,
	commentID string,
) ([]*CommentDraftBackup, error)

type CommentFilterOptions

type CommentFilterOptions struct {
	IsPublished *bool
	Labels      *[]string
}

func (*CommentFilterOptions) SQL

func (src *CommentFilterOptions) SQL(from string, args *pgx.QueryArgs) *SQLParts

type Course

type Course struct {
	AdvancedAt  pgtype.Timestamptz  `db:"advanced_at" permit:"read"`
	CompletedAt pgtype.Timestamptz  `db:"completed_at" permit:"read"`
	AppledAt    pgtype.Timestamptz  `db:"appled_at"`
	CreatedAt   pgtype.Timestamptz  `db:"created_at" permit:"read"`
	Description pgtype.Text         `db:"description" permit:"create/read/update"`
	ID          mytype.OID          `db:"id" permit:"read"`
	Name        pgtype.Text         `db:"name" permit:"create/read"`
	Number      pgtype.Int4         `db:"number" permit:"read/update"`
	PublishedAt pgtype.Timestamptz  `db:"published_at" permit:"read/update"`
	Status      mytype.CourseStatus `db:"status" permit:"read/update"`
	StudyID     mytype.OID          `db:"study_id" permit:"create/read"`
	TopicedAt   pgtype.Timestamptz  `db:"topiced_at"`
	UpdatedAt   pgtype.Timestamptz  `db:"updated_at" permit:"read"`
	UserID      mytype.OID          `db:"user_id" permit:"create/read"`
}

func CreateCourse

func CreateCourse(
	db Queryer,
	row *Course,
) (*Course, error)

func GetCourse

func GetCourse(
	db Queryer,
	id string,
) (*Course, error)

func GetCourseByApplee

func GetCourseByApplee(
	db Queryer,
	appleeID string,
	po *PageOptions,
	filters *CourseFilterOptions,
) ([]*Course, error)

func GetCourseByName

func GetCourseByName(
	db Queryer,
	studyID,
	name string,
) (*Course, error)

func GetCourseByNumber

func GetCourseByNumber(
	db Queryer,
	studyID string,
	number int32,
) (*Course, error)

func GetCourseByStudy

func GetCourseByStudy(
	db Queryer,
	studyID string,
	po *PageOptions,
	filters *CourseFilterOptions,
) ([]*Course, error)

func GetCourseByStudyAndName

func GetCourseByStudyAndName(
	db Queryer,
	study,
	name string,
) (*Course, error)

func GetCourseByTopic

func GetCourseByTopic(
	db Queryer,
	topicID string,
	po *PageOptions,
	filters *CourseFilterOptions,
) ([]*Course, error)

func GetCourseByUser

func GetCourseByUser(
	db Queryer,
	userID string,
	po *PageOptions,
	filters *CourseFilterOptions,
) ([]*Course, error)

func SearchCourse

func SearchCourse(
	db Queryer,
	po *PageOptions,
	filters *CourseFilterOptions,
) ([]*Course, error)

func UpdateCourse

func UpdateCourse(
	db Queryer,
	row *Course,
) (*Course, error)

type CourseEventPayload

type CourseEventPayload struct {
	Action   string     `json:"action,omitempty"`
	CourseID mytype.OID `json:"course_id,omitempty"`
}

func NewCourseAppledPayload

func NewCourseAppledPayload(courseID *mytype.OID) (*CourseEventPayload, error)

func NewCourseCreatedPayload

func NewCourseCreatedPayload(courseID *mytype.OID) (*CourseEventPayload, error)

func NewCoursePublishedPayload

func NewCoursePublishedPayload(courseID *mytype.OID) (*CourseEventPayload, error)

func NewCourseUnappledPayload

func NewCourseUnappledPayload(courseID *mytype.OID) (*CourseEventPayload, error)

type CourseFilterOptions

type CourseFilterOptions struct {
	IsPublished *bool
	Topics      *[]string
	Search      *string
}

func (*CourseFilterOptions) SQL

func (src *CourseFilterOptions) SQL(from string, args *pgx.QueryArgs) *SQLParts

type CourseLesson

type CourseLesson struct {
	CreatedAt pgtype.Timestamptz `db:"created_at" permit:"read"`
	CourseID  mytype.OID         `db:"course_id" permit:"read"`
	LessonID  mytype.OID         `db:"lesson_id" permit:"read"`
	Number    pgtype.Int4        `db:"number" permit:"read/update"`
}

func CreateCourseLesson

func CreateCourseLesson(
	db Queryer,
	row CourseLesson,
) (*CourseLesson, error)

func GetCourseLesson

func GetCourseLesson(
	db Queryer,
	lessonID string,
) (*CourseLesson, error)

func GetCourseLessonByCourse

func GetCourseLessonByCourse(
	db Queryer,
	courseID string,
	po *PageOptions,
) ([]*CourseLesson, error)

func GetCourseLessonByCourseAndNumber

func GetCourseLessonByCourseAndNumber(
	db Queryer,
	courseID string,
	number int32,
) (*CourseLesson, error)

func MoveCourseLesson

func MoveCourseLesson(
	db Queryer,
	courseID,
	lessonID,
	afterLessonID string,
) (*CourseLesson, error)

type Cursor

type Cursor struct {
	String string
	Value  string
}

func NewCursor

func NewCursor(cursor string) (*Cursor, error)

func (*Cursor) SQL

func (c *Cursor) SQL(field string, args *pgx.QueryArgs) string

type DataEndUserError

type DataEndUserError struct {
	Code    PSQLError
	Message string
}

Errors of this type may be seen by the end user.

func (DataEndUserError) Error

func (e DataEndUserError) Error() string

type DataFieldError

type DataFieldError struct {
	Code  DataFieldErrorCode
	Field string
}

func DuplicateFieldError

func DuplicateFieldError(field string) DataFieldError

func RequiredFieldError

func RequiredFieldError(field string) DataFieldError

func (DataFieldError) Error

func (e DataFieldError) Error() string

type DataFieldErrorCode

type DataFieldErrorCode int
const (
	UnknownDataFieldErrorCode DataFieldErrorCode = iota
	DuplicateField
	RequiredField
)

func (DataFieldErrorCode) String

func (c DataFieldErrorCode) String() string

type EVT

type EVT struct {
	EmailID    mytype.OID         `db:"email_id" permit:"create/read"`
	ExpiresAt  pgtype.Timestamptz `db:"expires_at" permit:"read"`
	IssuedAt   pgtype.Timestamptz `db:"issued_at" permit:"read"`
	Token      pgtype.Varchar     `db:"token" permit:"read"`
	UserID     mytype.OID         `db:"user_id" permit:"create/read"`
	VerifiedAt pgtype.Timestamptz `db:"verified_at" permit:"read/update"`
}

func CreateEVT

func CreateEVT(
	db Queryer,
	row *EVT,
) (*EVT, error)

func GetEVT

func GetEVT(
	db Queryer,
	emailID,
	token string,
) (*EVT, error)

func UpdateEVT

func UpdateEVT(
	db Queryer,
	row *EVT,
) (*EVT, error)

type Email

type Email struct {
	CreatedAt  pgtype.Timestamptz `db:"created_at" permit:"read"`
	ID         mytype.OID         `db:"id" permit:"read"`
	Public     pgtype.Bool        `db:"public" permit:"read"`
	Type       mytype.EmailType   `db:"type" permit:"create/read/update"`
	UserID     mytype.OID         `db:"user_id" permit:"create/read"`
	UpdatedAt  pgtype.Timestamptz `db:"updated_at" permit:"read"`
	Value      pgtype.Varchar     `db:"value" permit:"create/read"`
	VerifiedAt pgtype.Timestamptz `db:"verified_at" permit:"read/update"`
}

func CreateEmail

func CreateEmail(db Queryer, row *Email) (*Email, error)

func GetEmail

func GetEmail(db Queryer, id string) (*Email, error)

func GetEmailByUser

func GetEmailByUser(
	db Queryer,
	userID string,
	po *PageOptions,
	filters *EmailFilterOptions,
) ([]*Email, error)

func GetEmailByValue

func GetEmailByValue(db Queryer, value string) (*Email, error)

func UpdateEmail

func UpdateEmail(db Queryer, row *Email) (*Email, error)

type EmailFilterOptions

type EmailFilterOptions struct {
	IsVerified *bool
	Types      *[]string
}

func (*EmailFilterOptions) SQL

func (src *EmailFilterOptions) SQL(from string, args *pgx.QueryArgs) *SQLParts

type Enrolled

type Enrolled struct {
	CreatedAt    pgtype.Timestamptz      `db:"created_at" permit:"read"`
	ID           pgtype.Int4             `db:"id" permit:"read"`
	EnrollableID mytype.OID              `db:"enrollable_id" permit:"read"`
	ReasonName   pgtype.Varchar          `db:"reason_name" permit:"read"`
	Status       mytype.EnrollmentStatus `db:"status" permit:"read/update"`
	Type         pgtype.Text             `db:"type" permit:"read"`
	UserID       mytype.OID              `db:"user_id" permit:"read"`
}

func CreateEnrolled

func CreateEnrolled(
	db Queryer,
	row Enrolled,
) (*Enrolled, error)

func GetEnrolled

func GetEnrolled(
	db Queryer,
	id int32,
) (*Enrolled, error)

func GetEnrolledByEnrollable

func GetEnrolledByEnrollable(
	db Queryer,
	enrollableID string,
	po *PageOptions,
	filters *EnrolledFilterOptions,
) ([]*Enrolled, error)

func GetEnrolledByEnrollableAndUser

func GetEnrolledByEnrollableAndUser(
	db Queryer,
	enrollableID,
	userID string,
) (*Enrolled, error)

func GetEnrolledByUser

func GetEnrolledByUser(
	db Queryer,
	userID string,
	po *PageOptions,
	filters *EnrolledFilterOptions,
) ([]*Enrolled, error)

func UpdateEnrolled

func UpdateEnrolled(
	db Queryer,
	row *Enrolled,
) (*Enrolled, error)

type EnrolledFilterOptions

type EnrolledFilterOptions struct {
	Status *[]string
	Types  *[]string
}

func (*EnrolledFilterOptions) SQL

func (src *EnrolledFilterOptions) SQL(from string, args *pgx.QueryArgs) *SQLParts

type Event

type Event struct {
	Action    mytype.EventAction `db:"action" permit"read"`
	CreatedAt pgtype.Timestamptz `db:"created_at" permit:"read"`
	ID        mytype.OID         `db:"id" permit:"read"`
	Payload   pgtype.JSONB       `db:"payload" permit:"create/read"`
	Public    pgtype.Bool        `db:"public" permit:"create/read"`
	StudyID   mytype.OID         `db:"study_id" permit:"create/read"`
	Type      pgtype.Text        `db:"type" permit:"create/read"`
	UserID    mytype.OID         `db:"user_id" permit:"create/read"`
}

func CreateEvent

func CreateEvent(
	db Queryer,
	row *Event,
) (*Event, error)

func GetEvent

func GetEvent(
	db Queryer,
	id string,
) (*Event, error)

func GetEventByLesson

func GetEventByLesson(
	db Queryer,
	lessonID string,
	po *PageOptions,
	filters *EventFilterOptions,
) ([]*Event, error)

func GetEventByStudy

func GetEventByStudy(
	db Queryer,
	studyID string,
	po *PageOptions,
	filters *EventFilterOptions,
) ([]*Event, error)

func GetEventByUser

func GetEventByUser(
	db Queryer,
	userID string,
	po *PageOptions,
	filters *EventFilterOptions,
) ([]*Event, error)

func GetEventByUserAsset

func GetEventByUserAsset(
	db Queryer,
	assetID string,
	po *PageOptions,
	filters *EventFilterOptions,
) ([]*Event, error)

func GetReceivedEventByUser

func GetReceivedEventByUser(
	db Queryer,
	userID string,
	po *PageOptions,
	filters *EventFilterOptions,
) ([]*Event, error)

func NewActivityEvent

func NewActivityEvent(payload *ActivityEventPayload, studyID, userID *mytype.OID, public bool) (*Event, error)

func NewCourseEvent

func NewCourseEvent(payload *CourseEventPayload, studyID, userID *mytype.OID, public bool) (*Event, error)

func NewLessonEvent

func NewLessonEvent(payload *LessonEventPayload, studyID, userID *mytype.OID, public bool) (*Event, error)

func NewStudyEvent

func NewStudyEvent(payload *StudyEventPayload, studyID, userID *mytype.OID, public bool) (*Event, error)

func NewUserAssetEvent

func NewUserAssetEvent(payload *UserAssetEventPayload, studyID, userID *mytype.OID, public bool) (*Event, error)

type EventFilterOptions

type EventFilterOptions struct {
	IsPublic *bool
	Types    *[]EventTypeFilter
}

func (*EventFilterOptions) SQL

func (src *EventFilterOptions) SQL(from string, args *pgx.QueryArgs) *SQLParts

type EventTypeFilter

type EventTypeFilter struct {
	ActionIs    *[]string
	ActionIsNot *[]string
	Type        string
}

type FilterOptions

type FilterOptions interface {
	SQL(from string, args *pgx.QueryArgs) *SQLParts
}

type Label

type Label struct {
	Color       mytype.Color       `db:"color" permit:"create/read/update"`
	CreatedAt   pgtype.Timestamptz `db:"created_at" permit:"read"`
	Description pgtype.Text        `db:"description" permit:"create/read/update"`
	ID          mytype.OID         `db:"id" permit:"read"`
	IsDefault   pgtype.Bool        `db:"is_default" permit:"read"`
	LabelableID mytype.OID         `db:"labelable_id"`
	LabeledAt   pgtype.Timestamptz `db:"labeled_at"`
	Name        mytype.WordsName   `db:"name" permit:"create/read"`
	StudyID     mytype.OID         `db:"study_id" permit:"create/read"`
	UpdatedAt   pgtype.Timestamptz `db:"updated_at" permit:"read"`
}

func CreateLabel

func CreateLabel(
	db Queryer,
	row *Label,
) (*Label, error)

func GetLabel

func GetLabel(
	db Queryer,
	id string,
) (*Label, error)

func GetLabelByLabelable

func GetLabelByLabelable(
	db Queryer,
	labelableID string,
	po *PageOptions,
	filters *LabelFilterOptions,
) ([]*Label, error)

func GetLabelByName

func GetLabelByName(
	db Queryer,
	studyID,
	name string,
) (*Label, error)

func GetLabelByStudy

func GetLabelByStudy(
	db Queryer,
	studyID string,
	po *PageOptions,
	filters *LabelFilterOptions,
) ([]*Label, error)

func SearchLabel

func SearchLabel(
	db Queryer,
	po *PageOptions,
	filters *LabelFilterOptions,
) ([]*Label, error)

func UpdateLabel

func UpdateLabel(
	db Queryer,
	row *Label,
) (*Label, error)

type LabelFilterOptions

type LabelFilterOptions struct {
	IsDefault *bool
	Search    *string
}

func (*LabelFilterOptions) SQL

func (src *LabelFilterOptions) SQL(from string, args *pgx.QueryArgs) *SQLParts

type Labeled

type Labeled struct {
	CreatedAt   pgtype.Timestamptz `db:"created_at" permit:"read"`
	ID          pgtype.Int4        `db:"id" permit:"read"`
	LabelID     mytype.OID         `db:"label_id" permit:"read"`
	LabelableID mytype.OID         `db:"labelable_id" permit:"read"`
	Type        pgtype.Text        `db:"type" permit:"read"`
}

func CreateLabeled

func CreateLabeled(
	db Queryer,
	row Labeled,
) (*Labeled, error)

func GetLabeled

func GetLabeled(
	db Queryer,
	id int32,
) (*Labeled, error)

func GetLabeledByLabel

func GetLabeledByLabel(
	db Queryer,
	labelID string,
	po *PageOptions,
) ([]*Labeled, error)

func GetLabeledByLabelable

func GetLabeledByLabelable(
	db Queryer,
	labelableID string,
	po *PageOptions,
) ([]*Labeled, error)

func GetLabeledByLabelableAndLabel

func GetLabeledByLabelableAndLabel(
	db Queryer,
	labelableID,
	labelID string,
) (*Labeled, error)

type Lesson

type Lesson struct {
	Body         mytype.Markdown    `db:"body" permit:"create/read/update"`
	CourseID     mytype.OID         `db:"course_id" permit:"read"`
	CourseNumber pgtype.Int4        `db:"course_number" permit:"read"`
	CreatedAt    pgtype.Timestamptz `db:"created_at" permit:"read"`
	Draft        pgtype.Text        `db:"draft" permit:"read/update"`
	EnrolledAt   pgtype.Timestamptz `db:"enrolled_at"`
	ID           mytype.OID         `db:"id" permit:"read"`
	LabeledAt    pgtype.Timestamptz `db:"labeled_at"`
	LastEditedAt pgtype.Timestamptz `db:"last_edited_at" permit:"read"`
	Number       pgtype.Int4        `db:"number" permit:"read"`
	PublishedAt  pgtype.Timestamptz `db:"published_at" permit:"read/update"`
	StudyID      mytype.OID         `db:"study_id" permit:"create/read"`
	Title        pgtype.Text        `db:"title" permit:"create/read/update"`
	UpdatedAt    pgtype.Timestamptz `db:"updated_at" permit:"read"`
	UserID       mytype.OID         `db:"user_id" permit:"create/read"`
}

func BatchGetLessonByNumber

func BatchGetLessonByNumber(
	db Queryer,
	studyID string,
	numbers []int32,
) ([]*Lesson, error)

func CreateLesson

func CreateLesson(
	db Queryer,
	row *Lesson,
) (*Lesson, error)

func GetLesson

func GetLesson(
	db Queryer,
	id string,
) (*Lesson, error)

func GetLessonByCourse

func GetLessonByCourse(
	db Queryer,
	courseID string,
	po *PageOptions,
	filters *LessonFilterOptions,
) ([]*Lesson, error)

func GetLessonByCourseNumber

func GetLessonByCourseNumber(
	db Queryer,
	courseID string,
	courseNumber int32,
) (*Lesson, error)

func GetLessonByEnrollee

func GetLessonByEnrollee(
	db Queryer,
	enrolleeID string,
	po *PageOptions,
	filters *LessonFilterOptions,
) ([]*Lesson, error)

func GetLessonByLabel

func GetLessonByLabel(
	db Queryer,
	labelID string,
	po *PageOptions,
	filters *LessonFilterOptions,
) ([]*Lesson, error)

func GetLessonByNumber

func GetLessonByNumber(
	db Queryer,
	studyID string,
	number int32,
) (*Lesson, error)

func GetLessonByOwnerStudyAndNumber

func GetLessonByOwnerStudyAndNumber(
	db Queryer,
	ownerLogin,
	studyName string,
	number int32,
) (*Lesson, error)

func GetLessonByStudy

func GetLessonByStudy(
	db Queryer,
	studyID string,
	po *PageOptions,
	filters *LessonFilterOptions,
) ([]*Lesson, error)

func GetLessonByUser

func GetLessonByUser(
	db Queryer,
	userID string,
	po *PageOptions,
	filters *LessonFilterOptions,
) ([]*Lesson, error)

func SearchLesson

func SearchLesson(
	db Queryer,
	po *PageOptions,
	filters *LessonFilterOptions,
) ([]*Lesson, error)

func UpdateLesson

func UpdateLesson(
	db Queryer,
	row *Lesson,
) (*Lesson, error)

type LessonDraftBackup

type LessonDraftBackup struct {
	CreatedAt pgtype.Timestamptz `db:"created_at" permit:"read"`
	Draft     pgtype.Text        `db:"draft" permit:"read"`
	ID        pgtype.Int4        `db:"id" permit:"read"`
	LessonID  mytype.OID         `db:"lesson_id" permit:"read"`
	UpdatedAt pgtype.Timestamptz `db:"updated_at" permit:"read"`
}

func GetLessonDraftBackup

func GetLessonDraftBackup(
	db Queryer,
	lessonID string,
	id int32,
) (*LessonDraftBackup, error)

func GetLessonDraftBackupByLesson

func GetLessonDraftBackupByLesson(
	db Queryer,
	lessonID string,
) ([]*LessonDraftBackup, error)

type LessonEventPayload

type LessonEventPayload struct {
	Action    string        `json:"action,omitempty"`
	CommentID mytype.OID    `json:"comment_id,omitempty"`
	CourseID  mytype.OID    `json:"course_id,omitempty"`
	LabelID   mytype.OID    `json:"label_id,omitempty"`
	LessonID  mytype.OID    `json:"lesson_id,omitempty"`
	Rename    RenamePayload `json:"rename,omitempty"`
	SourceID  mytype.OID    `json:"source_id,omitempty"`
}

func NewLessonAddedToCoursePayload

func NewLessonAddedToCoursePayload(lessonID, courseID *mytype.OID) (*LessonEventPayload, error)

func NewLessonCommentedPayload

func NewLessonCommentedPayload(lessonID, commentID *mytype.OID) (*LessonEventPayload, error)

func NewLessonCreatedPayload

func NewLessonCreatedPayload(lessonID *mytype.OID) (*LessonEventPayload, error)

func NewLessonLabeledPayload

func NewLessonLabeledPayload(lessonID, labelID *mytype.OID) (*LessonEventPayload, error)

func NewLessonMentionedPayload

func NewLessonMentionedPayload(lessonID *mytype.OID) (*LessonEventPayload, error)

func NewLessonPublishedPayload

func NewLessonPublishedPayload(lessonID *mytype.OID) (*LessonEventPayload, error)

func NewLessonReferencedPayload

func NewLessonReferencedPayload(lessonID, sourceID *mytype.OID) (*LessonEventPayload, error)

func NewLessonRemovedFromCoursePayload

func NewLessonRemovedFromCoursePayload(lessonID, courseID *mytype.OID) (*LessonEventPayload, error)

func NewLessonRenamedPayload

func NewLessonRenamedPayload(lessonID *mytype.OID, from, to string) (*LessonEventPayload, error)

func NewLessonUnlabeledPayload

func NewLessonUnlabeledPayload(lessonID, labelID *mytype.OID) (*LessonEventPayload, error)

type LessonFilterOptions

type LessonFilterOptions struct {
	IsCourseLesson   *bool
	IsPublished      *bool
	Labels           *[]string
	CourseNotEqualTo *string
	Search           *string
}

func (*LessonFilterOptions) SQL

func (src *LessonFilterOptions) SQL(from string, args *pgx.QueryArgs) *SQLParts

type Notification

type Notification struct {
	CreatedAt  pgtype.Timestamptz `db:"created_at" permit:"read"`
	ID         mytype.OID         `db:"id" permit:"read"`
	LastReadAt pgtype.Timestamptz `db:"last_read_at" permit:"read"`
	Reason     pgtype.Text        `db:"reason" permit:"read"`
	ReasonName pgtype.Varchar     `db:"reason_name"`
	Subject    pgtype.Text        `db:"subject" permit:"read"`
	SubjectID  mytype.OID         `db:"subject_id" permit:"read"`
	StudyID    mytype.OID         `db:"study_id" permit:"read"`
	Unread     pgtype.Bool        `db:"unread" permit:"read"`
	UpdatedAt  pgtype.Timestamptz `db:"updated_at" permit:"read"`
	UserID     mytype.OID         `db:"user_id" permit:"read"`
}

func CreateNotification

func CreateNotification(
	db Queryer,
	row *Notification,
) (*Notification, error)

func GetNotification

func GetNotification(
	db Queryer,
	id string,
) (*Notification, error)

func GetNotificationByStudy

func GetNotificationByStudy(
	db Queryer,
	studyID string,
	po *PageOptions,
) ([]*Notification, error)

func GetNotificationByUser

func GetNotificationByUser(
	db Queryer,
	userID string,
	po *PageOptions,
) ([]*Notification, error)

type Order

type Order interface {
	Direction() OrderDirection
	Field() string
}

type OrderDirection

type OrderDirection bool
const (
	ASC  OrderDirection = false
	DESC OrderDirection = true
)

func ParseOrderDirection

func ParseOrderDirection(s string) (OrderDirection, error)

func (OrderDirection) String

func (od OrderDirection) String() string

type PRT

type PRT struct {
	EmailID   mytype.OID         `db:"email_id" permit:"create/read"`
	EndedAt   pgtype.Timestamptz `db:"ended_at" permit:"read/update"`
	EndIP     pgtype.Inet        `db:"end_ip" permit:"read/update"`
	ExpiresAt pgtype.Timestamptz `db:"expires_at" permit:"create/read"`
	IssuedAt  pgtype.Timestamptz `db:"issued_at" permit:"create/read"`
	RequestIP pgtype.Inet        `db:"request_ip" permit:"create/read"`
	UserID    mytype.OID         `db:"user_id" permit:"create/read"`
	Token     pgtype.Varchar     `db:"token" permit:"create/read"`
}

func CreatePRT

func CreatePRT(
	db Queryer,
	row *PRT,
) (*PRT, error)

func GetPRT

func GetPRT(
	db Queryer,
	userID,
	token string,
) (*PRT, error)

func UpdatePRT

func UpdatePRT(
	db Queryer,
	row *PRT,
) (*PRT, error)

type PSQLError

type PSQLError string
const (
	UnknownPSQLError = "?????"
	// Class 00 — Successful Completion
	SuccessfulCompletion PSQLError = "00000"
	// Class 01 — Warning
	Warning                          PSQLError = "01000"
	DynamicResultSetsReturned        PSQLError = "0100C"
	ImplicitZeroBitPadding           PSQLError = "01008"
	NullValueEliminatedInSetFunction PSQLError = "01003"
	PrivilegeNotGranted              PSQLError = "01007"
	PrivilegeNotRevoked              PSQLError = "01006"
	WarningStringDataRightTruncation PSQLError = "01004"
	DeprecatedFeature                PSQLError = "01P01"
	// Class 02 — No Data (this is also a warning class per the SQL standard)
	NoData                                PSQLError = "02000"
	NoAdditionalDynamicResultSetsReturned PSQLError = "02001"
	// Class 03 — SQL Statement Not Yet Complete
	SqlStatementNotYetComplete PSQLError = "03000"
	// Class 08 — Connection Exception
	ConnectionException                           PSQLError = "08000"
	ConnectionDoesNotExist                        PSQLError = "08003"
	ConnectionFailure                             PSQLError = "08006"
	SqlclientUnableToEstablishSqlconnection       PSQLError = "08001"
	SqlserverRejectedEstablishmentOfSqlconnection PSQLError = "08004"
	TransactionResolutionUnknown                  PSQLError = "08007"
	ProtocolViolation                             PSQLError = "08P01"
	// Class 09 — Triggered Action Exception
	TriggeredActionException PSQLError = "09000"
	// Class 0A — Feature Not Supported
	FeatureNotSupported PSQLError = "0A000"
	// Class 0B — Invalid Transaction Initiation
	InvalidTransactionInitiation PSQLError = "0B000"
	// Class 0F — Locator Exception
	LocatorException            PSQLError = "0F000"
	InvalidLocatorSpecification PSQLError = "0F001"
	// Class 0L — Invalid Grantor
	InvalidGrantor        PSQLError = "0L000"
	InvalidGrantOperation PSQLError = "0LP01"
	// Class 0P — Invalid Role Specification
	InvalidRoleSpecification PSQLError = "0P000"
	// Class 0Z — Diagnostics Exception
	DiagnosticsException                           PSQLError = "0Z000"
	StackedDiagnosticsAccessedWithoutActiveHandler PSQLError = "0Z002"
	// Class 20 — Case Not Found
	CaseNotFound PSQLError = "20000"
	// Class 21 — Cardinality Violation
	CardinalityViolation PSQLError = "21000"
	// Class 22 — Data Exception
	DataException                         PSQLError = "22000"
	ArraySubscriptError                   PSQLError = "2202E"
	CharacterNotInRepertoire              PSQLError = "22021"
	DatetimeFieldOverflow                 PSQLError = "22008"
	DivisionByZero                        PSQLError = "22012"
	ErrorInAssignment                     PSQLError = "22005"
	EscapeCharacterConflict               PSQLError = "2200B"
	IndicatorOverflow                     PSQLError = "22022"
	IntervalFieldOverflow                 PSQLError = "22015"
	InvalidArgumentForLogarithm           PSQLError = "2201E"
	InvalidArgumentForNtileFunction       PSQLError = "22014"
	InvalidArgumentForNthValueFunction    PSQLError = "22016"
	InvalidArgumentForPowerFunction       PSQLError = "2201F"
	InvalidArgumentForWidthBucketFunction PSQLError = "2201G"
	InvalidCharacterValueForCast          PSQLError = "22018"
	InvalidDatetimeFormat                 PSQLError = "22007"
	InvalidEscapeCharacter                PSQLError = "22019"
	InvalidEscapeOctet                    PSQLError = "2200D"
	InvalidEscapeSequence                 PSQLError = "22025"
	NonstandardUseOfEscapeCharacter       PSQLError = "22P06"
	InvalidIndicatorParameterValue        PSQLError = "22010"
	InvalidParameterValue                 PSQLError = "22023"
	InvalidRegularExpression              PSQLError = "2201B"
	InvalidRowCountInLimitClause          PSQLError = "2201W"
	InvalidRowCountInResultOffsetClause   PSQLError = "2201X"
	InvalidTimeZoneDisplacementValue      PSQLError = "22009"
	InvalidUseOfEscapeCharacter           PSQLError = "2200C"
	MostSpecificTypeMismatch              PSQLError = "2200G"
	NullValueNotAllowed                   PSQLError = "22004"
	NullValueNoIndicatorParameter         PSQLError = "22002"
	NumericValueOutOfRange                PSQLError = "22003"
	StringDataLengthMismatch              PSQLError = "22026"
	StringDataRightTruncation             PSQLError = "22001"
	SubstringError                        PSQLError = "22011"
	TrimError                             PSQLError = "22027"
	UnterminatedCString                   PSQLError = "22024"
	ZeroLengthCharacterString             PSQLError = "2200F"
	FloatingPointException                PSQLError = "22P01"
	InvalidTextRepresentation             PSQLError = "22P02"
	InvalidBinaryRepresentation           PSQLError = "22P03"
	BadCopyFileFormat                     PSQLError = "22P04"
	UntranslatableCharacter               PSQLError = "22P05"
	NotAnXmlDocument                      PSQLError = "2200L"
	InvalidXmlDocument                    PSQLError = "2200M"
	InvalidXmlContent                     PSQLError = "2200N"
	InvalidXmlComment                     PSQLError = "2200S"
	InvalidXmlProcessingInstruction       PSQLError = "2200T"
	// Class 23 — Integrity Constraint Violation
	IntegrityConstraintViolation PSQLError = "23000"
	RestrictViolation            PSQLError = "23001"
	NotNullViolation             PSQLError = "23502"
	ForeignKeyViolation          PSQLError = "23503"
	UniqueViolation              PSQLError = "23505"
	CheckViolation               PSQLError = "23514"
	ExclusionViolation           PSQLError = "23P01"
	// Class 24 — Invalid Cursor State
	InvalidCursorState PSQLError = "24000"
	// Class 25 — Invalid Transaction State
	InvalidTransactionState                         PSQLError = "25000"
	ActiveSqlTransaction                            PSQLError = "25001"
	BranchTransactionAlreadyActive                  PSQLError = "25002"
	HeldCursorRequiresSameIsolationLevel            PSQLError = "25008"
	InappropriateAccessModeForBranchTransaction     PSQLError = "25003"
	InappropriateIsolationLevelForBranchTransaction PSQLError = "25004"
	NoActiveSqlTransactionForBranchTransaction      PSQLError = "25005"
	ReadOnlySqlTransaction                          PSQLError = "25006"
	SchemaAndDataStatementMixingNotSupported        PSQLError = "25007"
	NoActiveSqlTransaction                          PSQLError = "25P01"
	InFailedSqlTransaction                          PSQLError = "25P02"
	// Class 26 — Invalid SQL Statement Name
	InvalidSqlStatementName PSQLError = "26000"
	// Class 27 — Triggered Data Change Violation
	TriggeredDataChangeViolation PSQLError = "27000"
	// Class 28 — Invalid Authorization Specification
	InvalidAuthorizationSpecification PSQLError = "28000"
	InvalidPassword                   PSQLError = "28P01"
	// Class 2B — Dependent Privilege Descriptors Still Exist
	DependentPrivilegeDescriptorsStillExist PSQLError = "2B000"
	DependentObjectsStillExist              PSQLError = "2BP01"
	// Class 2D — Invalid Transaction Termination
	InvalidTransactionTermination PSQLError = "2D000"
	// Class 2F — SQL Routine Exception
	SqlRoutineException               PSQLError = "2F000"
	FunctionExecutedNoReturnStatement PSQLError = "2F005"
	ModifyingSqlDataNotPermitted      PSQLError = "2F002"
	ProhibitedSqlStatementAttempted   PSQLError = "2F003"
	ReadingSqlDataNotPermitted        PSQLError = "2F004"
	// Class 34 — Invalid Cursor Name
	InvalidCursorName PSQLError = "34000"
	// Class 38 — External Routine Exception
	ExternalRoutineException           PSQLError = "38000"
	ContainingSqlNotPermitted          PSQLError = "38001"
	EreModifyingSqlDataNotPermitted    PSQLError = "38002"
	EreProhibitedSqlStatementAttempted PSQLError = "38003"
	EreReadingSqlDataNotPermitted      PSQLError = "38004"
	// Class 39 — External Routine Invocation Exception
	ExternalRoutineInvocationException PSQLError = "39000"
	InvalidSqlstateReturned            PSQLError = "39001"
	ErieNullValueNotAllowed            PSQLError = "39004"
	TriggerProtocolViolated            PSQLError = "39P01"
	SrfProtocolViolated                PSQLError = "39P02"
	// Class 3B — Savepoint Exception
	SavepointException            PSQLError = "3B000"
	InvalidSavepointSpecification PSQLError = "3B001"
	// Class 3D — Invalid Catalog Name
	InvalidCatalogName PSQLError = "3D000"
	// Class 3F — Invalid Schema Name
	InvalidSchemaName PSQLError = "3F000"
	// Class 40 — Transaction Rollback
	TransactionRollback                     PSQLError = "40000"
	TransactionIntegrityConstraintViolation PSQLError = "40002"
	SerializationFailure                    PSQLError = "40001"
	StatementCompletionUnknown              PSQLError = "40003"
	DeadlockDetected                        PSQLError = "40P01"
	// Class 42 — Syntax Error or Access Rule Violation
	SyntaxErrorOrAccessRuleViolation   PSQLError = "42000"
	SyntaxError                        PSQLError = "42601"
	InsufficientPrivilege              PSQLError = "42501"
	CannotCoerce                       PSQLError = "42846"
	GroupingError                      PSQLError = "42803"
	WindowingError                     PSQLError = "42P20"
	InvalidRecursion                   PSQLError = "42P19"
	InvalidForeignKey                  PSQLError = "42830"
	InvalidName                        PSQLError = "42602"
	NameTooLong                        PSQLError = "42622"
	ReservedName                       PSQLError = "42939"
	DatatypeMismatch                   PSQLError = "42804"
	IndeterminateDatatype              PSQLError = "42P18"
	CollationMismatch                  PSQLError = "42P21"
	IndeterminateCollation             PSQLError = "42P22"
	WrongObjectType                    PSQLError = "42809"
	UndefinedColumn                    PSQLError = "42703"
	UndefinedFunction                  PSQLError = "42883"
	UndefinedTable                     PSQLError = "42P01"
	UndefinedParameter                 PSQLError = "42P02"
	UndefinedObject                    PSQLError = "42704"
	DuplicateColumn                    PSQLError = "42701"
	DuplicateCursor                    PSQLError = "42P03"
	DuplicateDatabase                  PSQLError = "42P04"
	DuplicateFunction                  PSQLError = "42723"
	DuplicatePreparedStatement         PSQLError = "42P05"
	DuplicateSchema                    PSQLError = "42P06"
	DuplicateTable                     PSQLError = "42P07"
	DuplicateAlias                     PSQLError = "42712"
	DuplicateObject                    PSQLError = "42710"
	AmbiguousColumn                    PSQLError = "42702"
	AmbiguousFunction                  PSQLError = "42725"
	AmbiguousParameter                 PSQLError = "42P08"
	AmbiguousAlias                     PSQLError = "42P09"
	InvalidColumnReference             PSQLError = "42P10"
	InvalidColumnDefinition            PSQLError = "42611"
	InvalidCursorDefinition            PSQLError = "42P11"
	InvalidDatabaseDefinition          PSQLError = "42P12"
	InvalidFunctionDefinition          PSQLError = "42P13"
	InvalidPreparedStatementDefinition PSQLError = "42P14"
	InvalidSchemaDefinition            PSQLError = "42P15"
	InvalidTableDefinition             PSQLError = "42P16"
	InvalidObjectDefinition            PSQLError = "42P17"
	// Class 44 — WITH CHECK OPTION Violation
	WithCheckOptionViolation PSQLError = "44000"
	// Class 53 — Insufficient Resources
	InsufficientResources      PSQLError = "53000"
	DiskFull                   PSQLError = "53100"
	OutOfMemory                PSQLError = "53200"
	TooManyConnections         PSQLError = "53300"
	ConfigurationLimitExceeded PSQLError = "53400"
	// Class 54 — Program Limit Exceeded
	ProgramLimitExceeded PSQLError = "54000"
	StatementTooComplex  PSQLError = "54001"
	TooManyColumns       PSQLError = "54011"
	TooManyArguments     PSQLError = "54023"
	// Class 55 — Object Not In Prerequisite State
	ObjectNotInPrerequisiteState PSQLError = "55000"
	ObjectInUse                  PSQLError = "55006"
	CantChangeRuntimeParam       PSQLError = "55P02"
	LockNotAvailable             PSQLError = "55P03"
	// Class 57 — Operator Intervention
	OperatorIntervention PSQLError = "57000"
	QueryCanceled        PSQLError = "57014"
	AdminShutdown        PSQLError = "57P01"
	CrashShutdown        PSQLError = "57P02"
	CannotConnectNow     PSQLError = "57P03"
	DatabaseDropped      PSQLError = "57P04"
	// Class 58 — System Error (errors external to PostgreSQL itself)
	SystemError   PSQLError = "58000"
	IoError       PSQLError = "58030"
	UndefinedFile PSQLError = "58P01"
	DuplicateFile PSQLError = "58P02"
	// Class F0 — Configuration File Error
	ConfigFileError PSQLError = "F0000"
	LockFileExists  PSQLError = "F0001"
	// Class HV — Foreign Data Wrapper Error (SQL/MED)
	FdwError                             PSQLError = "HV000"
	FdwColumnNameNotFound                PSQLError = "HV005"
	FdwDynamicParameterValueNeeded       PSQLError = "HV002"
	FdwFunctionSequenceError             PSQLError = "HV010"
	FdwInconsistentDescriptorInformation PSQLError = "HV021"
	FdwInvalidAttributeValue             PSQLError = "HV024"
	FdwInvalidColumnName                 PSQLError = "HV007"
	FdwInvalidColumnNumber               PSQLError = "HV008"
	FdwInvalidDataType                   PSQLError = "HV004"
	FdwInvalidDataTypeDescriptors        PSQLError = "HV006"
	FdwInvalidDescriptorFieldIdentifier  PSQLError = "HV091"
	FdwInvalidHandle                     PSQLError = "HV00B"
	FdwInvalidOptionIndex                PSQLError = "HV00C"
	FdwInvalidOptionName                 PSQLError = "HV00D"
	FdwInvalidStringLengthOrBufferLength PSQLError = "HV090"
	FdwInvalidStringFormat               PSQLError = "HV00A"
	FdwInvalidUseOfNullPointer           PSQLError = "HV009"
	FdwTooManyHandles                    PSQLError = "HV014"
	FdwOutOfMemory                       PSQLError = "HV001"
	FdwNoSchemas                         PSQLError = "HV00P"
	FdwOptionNameNotFound                PSQLError = "HV00J"
	FdwReplyHandle                       PSQLError = "HV00K"
	FdwSchemaNotFound                    PSQLError = "HV00Q"
	FdwTableNotFound                     PSQLError = "HV00R"
	FdwUnableToCreateExecution           PSQLError = "HV00L"
	FdwUnableToCreateReply               PSQLError = "HV00M"
	FdwUnableToEstablishConnection       PSQLError = "HV00N"
	// Class P0 — PL/pgSQL Error
	PlpgsqlError   PSQLError = "P0000"
	RaiseException PSQLError = "P0001"
	NoDataFound    PSQLError = "P0002"
	TooManyRows    PSQLError = "P0003"
	// Class XX — Internal Error
	InternalError  PSQLError = "XX000"
	DataCorrupted  PSQLError = "XX001"
	IndexCorrupted PSQLError = "XX002"
)

func (PSQLError) MarshalJSON

func (e PSQLError) MarshalJSON() ([]byte, error)

func (*PSQLError) UnmarshalJSON

func (e *PSQLError) UnmarshalJSON(b []byte) error

type PageOptions

type PageOptions struct {
	After  *Cursor
	Before *Cursor
	First  int32
	Last   int32
	Order  Order
}

func NewPageOptions

func NewPageOptions(after, before *string, first, last *int32, o Order) (*PageOptions, error)

func (*PageOptions) Limit

func (p *PageOptions) Limit() int32

func (*PageOptions) QueryDirection

func (p *PageOptions) QueryDirection() string

If the query is asking for the last elements in a list, then we need two queries to get the items more efficiently and in the right order. First, we query the reverse direction of that requested, so that only the items needed are returned.

type PermissableField

type PermissableField struct {
	Name string
	// contains filtered or unexported fields
}

func NewPermissableField

func NewPermissableField(f *structs.Field) (*PermissableField, error)

func (*PermissableField) Can

type PermissableFields

type PermissableFields []*PermissableField

func GetPermissableFields

func GetPermissableFields(model interface{}) (PermissableFields, error)

func (PermissableFields) Filter

func (PermissableFields) Names

func (fs PermissableFields) Names() []string

type Permission

type Permission struct {
	AccessLevel pgtype.Text        `db:"access_level"`
	Audience    pgtype.Text        `db:"audience"`
	CreatedAt   pgtype.Timestamptz `db:"created_at"`
	GrantedAt   pgtype.Timestamptz `db:"granted_at"`
	ID          mytype.OID         `db:"id"`
	Field       pgtype.Text        `db:"field"`
	Type        pgtype.Text        `db:"type"`
	UpdatedAt   pgtype.Timestamptz `db:"updated_at"`
}

func GetByRole

func GetByRole(
	db Queryer,
	role string,
) ([]Permission, error)

type QueryPermission

type QueryPermission struct {
	Operation mytype.Operation
	Audience  mytype.Audience
	Fields    pgtype.TextArray
}

func GetQueryPermission

func GetQueryPermission(
	db Queryer,
	o *mytype.Operation,
	roles []string,
) (*QueryPermission, error)

type Queryer

type Queryer interface {
	BeginBatch() *pgx.Batch
	CopyFrom(pgx.Identifier, []string, pgx.CopyFromSource) (int, error)
	Exec(sql string, arguments ...interface{}) (pgx.CommandTag, error)
	Query(sql string, args ...interface{}) (*pgx.Rows, error)
	QueryRow(sql string, args ...interface{}) *pgx.Row
}

func BeginTransaction

func BeginTransaction(db Queryer) (Queryer, error, bool)

type RenamePayload

type RenamePayload struct {
	From string `json:"from,omitempty"`
	To   string `json:"to,omitempty"`
}

type Role

type Role struct {
	CreatedAt   pgtype.Timestamptz `db:"created_at"`
	Description pgtype.Text        `db:"description"`
	GrantedAt   pgtype.Timestamptz `db:"granted_at"`
	Name        pgtype.Varchar     `db:"name"`
	UserID      mytype.OID         `db:"user_id"`
}

func GetRoleByUser

func GetRoleByUser(
	db Queryer,
	userID string,
	po *PageOptions,
) ([]*Role, error)

type SQLParts

type SQLParts struct {
	From  string
	Where string
}

type Study

type Study struct {
	AdvancedAt  pgtype.Timestamptz `db:"advanced_at" permit:"read"`
	AppledAt    pgtype.Timestamptz `db:"appled_at"`
	CreatedAt   pgtype.Timestamptz `db:"created_at" permit:"read"`
	Description pgtype.Text        `db:"description" permit:"create/read/update"`
	EnrolledAt  pgtype.Timestamptz `db:"enrolled_at"`
	ID          mytype.OID         `db:"id" permit:"read"`
	Name        mytype.WordsName   `db:"name" permit:"create/read"`
	Private     pgtype.Bool        `db:"private" permit:"create/read/update"`
	TopicedAt   pgtype.Timestamptz `db:"topiced_at"`
	UpdatedAt   pgtype.Timestamptz `db:"updated_at" permit:"read"`
	UserID      mytype.OID         `db:"user_id" permit:"create/read"`
}

func CreateStudy

func CreateStudy(
	db Queryer,
	row *Study,
) (*Study, error)

func GetStudy

func GetStudy(
	db Queryer,
	id string,
) (*Study, error)

func GetStudyByApplee

func GetStudyByApplee(
	db Queryer,
	appleeID string,
	po *PageOptions,
	filters *StudyFilterOptions,
) ([]*Study, error)

func GetStudyByEnrollee

func GetStudyByEnrollee(
	db Queryer,
	enrolleeID string,
	po *PageOptions,
	filters *StudyFilterOptions,
) ([]*Study, error)

func GetStudyByName

func GetStudyByName(
	db Queryer,
	userID,
	name string,
) (*Study, error)

func GetStudyByTopic

func GetStudyByTopic(
	db Queryer,
	topicID string,
	po *PageOptions,
	filters *StudyFilterOptions,
) ([]*Study, error)

func GetStudyByUser

func GetStudyByUser(
	db Queryer,
	userID string,
	po *PageOptions,
	filters *StudyFilterOptions,
) ([]*Study, error)

func GetStudyByUserAndName

func GetStudyByUserAndName(
	db Queryer,
	owner,
	name string,
) (*Study, error)

func SearchStudy

func SearchStudy(
	db Queryer,
	po *PageOptions,
	filters *StudyFilterOptions,
) ([]*Study, error)

func UpdateStudy

func UpdateStudy(
	db Queryer,
	row *Study,
) (*Study, error)

type StudyEventPayload

type StudyEventPayload struct {
	Action  string     `json:"action,omitempty"`
	StudyID mytype.OID `json:"study_id,omitempty"`
}

func NewStudyAppledPayload

func NewStudyAppledPayload(studyID *mytype.OID) (*StudyEventPayload, error)

func NewStudyCreatedPayload

func NewStudyCreatedPayload(studyID *mytype.OID) (*StudyEventPayload, error)

func NewStudyUnappledPayload

func NewStudyUnappledPayload(studyID *mytype.OID) (*StudyEventPayload, error)

type StudyFilterOptions

type StudyFilterOptions struct {
	Topics *[]string
	Search *string
}

func (*StudyFilterOptions) SQL

func (src *StudyFilterOptions) SQL(from string, args *pgx.QueryArgs) *SQLParts

type Topic

type Topic struct {
	CreatedAt   pgtype.Timestamptz `db:"created_at" permit:"read"`
	Description pgtype.Text        `db:"description" permit:"create/read/update"`
	ID          mytype.OID         `db:"id" permit:"read"`
	Name        mytype.WordName    `db:"name" permit:"create/read"`
	TopicableID mytype.OID         `db:"topicable_id"`
	TopicedAt   pgtype.Timestamptz `db:"topiced_at"`
	UpdatedAt   pgtype.Timestamptz `db:"updated_at" permit:"read"`
}

func CreateTopic

func CreateTopic(
	db Queryer,
	row *Topic,
) (*Topic, error)

func GetTopic

func GetTopic(
	db Queryer,
	id string,
) (*Topic, error)

func GetTopicByName

func GetTopicByName(
	db Queryer,
	name string,
) (*Topic, error)

func GetTopicByTopicable

func GetTopicByTopicable(
	db Queryer,
	topicableID string,
	po *PageOptions,
	filters *TopicFilterOptions,
) ([]*Topic, error)

func SearchTopic

func SearchTopic(
	db Queryer,
	po *PageOptions,
	filters *TopicFilterOptions,
) ([]*Topic, error)

func UpdateTopic

func UpdateTopic(
	db Queryer,
	row *Topic,
) (*Topic, error)

type TopicFilterOptions

type TopicFilterOptions struct {
	Search *string
}

func (*TopicFilterOptions) SQL

func (src *TopicFilterOptions) SQL(from string, args *pgx.QueryArgs) *SQLParts

type Topiced

type Topiced struct {
	CreatedAt   pgtype.Timestamptz `db:"created_at" permit:"read"`
	ID          pgtype.Int4        `db:"id" permit:"read"`
	TopicID     mytype.OID         `db:"topic_id" permit:"read"`
	TopicableID mytype.OID         `db:"topicable_id" permit:"read"`
	Type        pgtype.Text        `db:"type" permit:"read"`
}

func CreateTopiced

func CreateTopiced(
	db Queryer,
	row Topiced,
) (*Topiced, error)

func GetTopiced

func GetTopiced(
	db Queryer,
	id int32,
) (*Topiced, error)

func GetTopicedByTopic

func GetTopicedByTopic(
	db Queryer,
	topicID string,
	po *PageOptions,
) ([]*Topiced, error)

func GetTopicedByTopicable

func GetTopicedByTopicable(
	db Queryer,
	topicableID string,
	po *PageOptions,
) ([]*Topiced, error)

func GetTopicedByTopicableAndTopic

func GetTopicedByTopicableAndTopic(
	db Queryer,
	topicableID,
	topicID string,
) (*Topiced, error)

type User

type User struct {
	AccountUpdatedAt pgtype.Timestamptz `db:"account_updated_at" permit:"read"`
	AppledAt         pgtype.Timestamptz `db:"appled_at"`
	Bio              pgtype.Text        `db:"bio" permit:"read/update"`
	CreatedAt        pgtype.Timestamptz `db:"created_at" permit:"read"`
	EnrolledAt       pgtype.Timestamptz `db:"enrolled_at"`
	ID               mytype.OID         `db:"id" permit:"read"`
	Login            mytype.Username    `db:"login" permit:"read/create/update"`
	Name             pgtype.Text        `db:"name" permit:"read/update"`
	Password         mytype.Password    `db:"password" permit:"create/update"`
	PrimaryEmail     mytype.Email       `db:"primary_email" permit:"create"`
	ProfileEmailID   mytype.OID         `db:"profile_email_id" permit:"read/update"`
	ProfileUpdatedAt pgtype.Timestamptz `db:"profile_updated_at" permit:"read"`
	Roles            pgtype.TextArray   `db:"roles"`
	Verified         pgtype.Bool        `db:"verified" permit:"read"`
}

func BatchGetUser

func BatchGetUser(
	db Queryer,
	ids []string,
) ([]*User, error)

func BatchGetUserByLogin

func BatchGetUserByLogin(
	db Queryer,
	logins []string,
) ([]*User, error)

func CreateUser

func CreateUser(
	db Queryer,
	row *User,
) (*User, error)

func GetUser

func GetUser(
	db Queryer,
	id string,
) (*User, error)

func GetUserByAppleable

func GetUserByAppleable(
	db Queryer,
	appleableID string,
	po *PageOptions,
	filters *UserFilterOptions,
) ([]*User, error)

func GetUserByEnrollable

func GetUserByEnrollable(
	db Queryer,
	enrollableID string,
	po *PageOptions,
	filters *UserFilterOptions,
) ([]*User, error)

func GetUserByEnrollee

func GetUserByEnrollee(
	db Queryer,
	enrolleeID string,
	po *PageOptions,
	filters *UserFilterOptions,
) ([]*User, error)

func GetUserByLogin

func GetUserByLogin(
	db Queryer,
	login string,
) (*User, error)

func GetUserCredentials

func GetUserCredentials(
	db Queryer,
	id string,
) (*User, error)

func GetUserCredentialsByEmail

func GetUserCredentialsByEmail(
	db Queryer,
	email string,
) (*User, error)

func GetUserCredentialsByLogin

func GetUserCredentialsByLogin(
	db Queryer,
	login string,
) (*User, error)

func SearchUser

func SearchUser(
	db Queryer,
	po *PageOptions,
	filters *UserFilterOptions,
) ([]*User, error)

func UpdateUserAccount

func UpdateUserAccount(
	db Queryer,
	row *User,
) (*User, error)

func UpdateUserProfile

func UpdateUserProfile(
	db Queryer,
	row *User,
) (*User, error)

type UserAsset

type UserAsset struct {
	ActivityID     mytype.OID         `db:"activity_id" permit:"read"`
	ActivityNumber pgtype.Int4        `db:"activity_number" permit:"read"`
	AssetID        pgtype.Int8        `db:"asset_id" permit:"create/read"`
	CreatedAt      pgtype.Timestamptz `db:"created_at" permit:"read"`
	Description    pgtype.Text        `db:"description" permit:"create/read/update"`
	ID             mytype.OID         `db:"id" permit:"read"`
	Key            pgtype.Text        `db:"key" permit:"read"`
	LabeledAt      pgtype.Timestamptz `db:"labeled_at"`
	Name           mytype.Filename    `db:"name" permit:"create/read/update"`
	OriginalName   pgtype.Text        `db:"original_name" permit:"read"`
	Size           pgtype.Int8        `db:"size" permit:"read"`
	StudyID        mytype.OID         `db:"study_id" permit:"create/read"`
	Subtype        pgtype.Text        `db:"subtype" permit:"read"`
	Type           pgtype.Text        `db:"type" permit:"read"`
	UpdatedAt      pgtype.Timestamptz `db:"updated_at" permit:"read"`
	UserID         mytype.OID         `db:"user_id" permit:"create/read"`
}

func BatchGetUserAsset

func BatchGetUserAsset(
	db Queryer,
	ids []string,
) ([]*UserAsset, error)

func BatchGetUserAssetByName

func BatchGetUserAssetByName(
	db Queryer,
	studyID string,
	names []string,
) ([]*UserAsset, error)

func CreateUserAsset

func CreateUserAsset(
	db Queryer,
	row *UserAsset,
) (*UserAsset, error)

func GetUserAsset

func GetUserAsset(
	db Queryer,
	id string,
) (*UserAsset, error)

func GetUserAssetByActivity

func GetUserAssetByActivity(
	db Queryer,
	activityID string,
	po *PageOptions,
	filters *UserAssetFilterOptions,
) ([]*UserAsset, error)

func GetUserAssetByActivityNumber

func GetUserAssetByActivityNumber(
	db Queryer,
	activityID string,
	activityNumber int32,
) (*UserAsset, error)

func GetUserAssetByLabel

func GetUserAssetByLabel(
	db Queryer,
	labelID string,
	po *PageOptions,
	filters *UserAssetFilterOptions,
) ([]*UserAsset, error)

func GetUserAssetByName

func GetUserAssetByName(
	db Queryer,
	studyID,
	name string,
) (*UserAsset, error)

func GetUserAssetByStudy

func GetUserAssetByStudy(
	db Queryer,
	studyID string,
	po *PageOptions,
	filters *UserAssetFilterOptions,
) ([]*UserAsset, error)

func GetUserAssetByUser

func GetUserAssetByUser(
	db Queryer,
	userID string,
	po *PageOptions,
	filters *UserAssetFilterOptions,
) ([]*UserAsset, error)

func GetUserAssetByUserStudyAndName

func GetUserAssetByUserStudyAndName(
	db Queryer,
	owner,
	study,
	name string,
) (*UserAsset, error)

func NewUserAsset

func NewUserAsset(
	userID,
	studyID *mytype.OID,
	assetID int64,
	name string,
) (*UserAsset, error)

func SearchUserAsset

func SearchUserAsset(
	db Queryer,
	po *PageOptions,
	filters *UserAssetFilterOptions,
) ([]*UserAsset, error)

func UpdateUserAsset

func UpdateUserAsset(
	db Queryer,
	row *UserAsset,
) (*UserAsset, error)

type UserAssetEventPayload

type UserAssetEventPayload struct {
	Action     string        `json:"action,omitempty"`
	ActivityID mytype.OID    `json:"activity_id,omitempty"`
	AssetID    mytype.OID    `json:"asset_id,omitempty"`
	CommentID  mytype.OID    `json:"comment_id,omitempty"`
	LabelID    mytype.OID    `json:"label_id,omitempty"`
	Rename     RenamePayload `json:"rename,omitempty"`
	SourceID   mytype.OID    `json:"source_id,omitempty"`
}

func NewUserAssetAddedToActivityPayload

func NewUserAssetAddedToActivityPayload(assetID, activityID *mytype.OID) (*UserAssetEventPayload, error)

func NewUserAssetCommentedPayload

func NewUserAssetCommentedPayload(assetID, commentID *mytype.OID) (*UserAssetEventPayload, error)

func NewUserAssetCreatedPayload

func NewUserAssetCreatedPayload(assetID *mytype.OID) (*UserAssetEventPayload, error)

func NewUserAssetLabeledPayload

func NewUserAssetLabeledPayload(assetID, labelID *mytype.OID) (*UserAssetEventPayload, error)

func NewUserAssetMentionedPayload

func NewUserAssetMentionedPayload(assetID *mytype.OID) (*UserAssetEventPayload, error)

func NewUserAssetReferencedPayload

func NewUserAssetReferencedPayload(assetID, sourceID *mytype.OID) (*UserAssetEventPayload, error)

func NewUserAssetRemovedFromActivityPayload

func NewUserAssetRemovedFromActivityPayload(assetID, activityID *mytype.OID) (*UserAssetEventPayload, error)

func NewUserAssetRenamedPayload

func NewUserAssetRenamedPayload(assetID *mytype.OID, from, to string) (*UserAssetEventPayload, error)

func NewUserAssetUnlabeledPayload

func NewUserAssetUnlabeledPayload(assetID, labelID *mytype.OID) (*UserAssetEventPayload, error)

type UserAssetFilterOptions

type UserAssetFilterOptions struct {
	IsActivityAsset    *bool
	Labels             *[]string
	ActivityNotEqualTo *string
	Search             *string
}

func (*UserAssetFilterOptions) SQL

func (src *UserAssetFilterOptions) SQL(from string, args *pgx.QueryArgs) *SQLParts

type UserFilterOptions

type UserFilterOptions struct {
	Search *string
}

func (*UserFilterOptions) SQL

func (src *UserFilterOptions) SQL(from string, args *pgx.QueryArgs) *SQLParts

type WhereFrom

type WhereFrom = func(string) string

Jump to

Keyboard shortcuts

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