Documentation ¶
Index ¶
- func InitDatabase(ctx context.Context, opts Opts) (*mongo.Database, error)
- type LangModel
- type LangRepo
- func (r *LangRepo) Create(l *lang.Lang) error
- func (r *LangRepo) Delete(id, authorID string) error
- func (r *LangRepo) DeleteByAuthorID(authorID string) (int, error)
- func (r *LangRepo) Exist(id, authorID string) (bool, error)
- func (r *LangRepo) Get(id, authorID string) (*lang.Lang, error)
- func (r *LangRepo) GetAllViews(authorID string) ([]query.LangView, error)
- func (r *LangRepo) GetView(id, authorID string) (query.LangView, error)
- func (r *LangRepo) Update(l *lang.Lang) error
- type ListOptionsModel
- type Opts
- type TagModel
- type TagRepo
- func (r *TagRepo) AllExist(ids []string, authorID string) (bool, error)
- func (r *TagRepo) Create(t *tag.Tag) error
- func (r *TagRepo) Delete(id, authorID string) error
- func (r *TagRepo) DeleteByAuthorID(authorID string) (int, error)
- func (r *TagRepo) Get(id, authorID string) (*tag.Tag, error)
- func (r *TagRepo) GetAllViews(authorID string) ([]query.TagView, error)
- func (r *TagRepo) GetView(id, authorID string) (query.TagView, error)
- func (r *TagRepo) GetViews(ids []string, authorID string) ([]query.TagView, error)
- func (r *TagRepo) Update(t *tag.Tag) error
- type TranslationModel
- type TranslationRepo
- func (r *TranslationRepo) Create(t *translation.Translation) error
- func (r *TranslationRepo) Delete(id, authorID string) error
- func (r *TranslationRepo) DeleteByAuthorID(authorID string) (int, error)
- func (r *TranslationRepo) ExistByLang(langID, authorID string) (bool, error)
- func (r *TranslationRepo) ExistByTag(tagID, authorID string) (bool, error)
- func (r *TranslationRepo) Get(id, authorID string) (*translation.Translation, error)
- func (r *TranslationRepo) GetLastViewsBySourcePart(authorID, langID, sourcePart string, pageSize, page int) (query.LastTranslationViews, error)
- func (r *TranslationRepo) GetLastViewsByTags(authorID, langID string, pageSize, page int, tagIds []string) (query.LastTranslationViews, error)
- func (r *TranslationRepo) GetLastViewsByTargetPart(authorID, langID, targetPart string, pageSize, page int) (query.LastTranslationViews, error)
- func (r *TranslationRepo) GetRandomViews(authorID, langID string, tagIds []string, limit int) (query.RandomViews, error)
- func (r *TranslationRepo) GetView(id, authorID string) (query.TranslationView, error)
- func (r *TranslationRepo) Update(t *translation.Translation) error
- type UserModel
- type UserRepo
- func (r *UserRepo) Create(usr *user.User) error
- func (r *UserRepo) Delete(id string) (int, error)
- func (r *UserRepo) Get(id string) (*user.User, error)
- func (r *UserRepo) GetAllViews() ([]query.UserView, error)
- func (r *UserRepo) GetByEmail(email string) (*user.User, error)
- func (r *UserRepo) GetView(id string) (query.UserView, error)
- func (r *UserRepo) Update(usr *user.User) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LangRepo ¶
type LangRepo struct {
// contains filtered or unexported fields
}
func (*LangRepo) DeleteByAuthorID ¶
func (*LangRepo) GetAllViews ¶
type ListOptionsModel ¶
type ListOptionsModel struct {
HideTranscription bool `bson:"hide_transcription"`
}
ListOptionsModel represents the nested list options in the mongo user document
type TagModel ¶
type TagModel struct { ID string `bson:"_id"` Name string `bson:"name"` AuthorID string `bson:"author_id"` }
TagModel represents mongo tag document
type TagRepo ¶
type TagRepo struct {
// contains filtered or unexported fields
}
TagRepo Mongo DB implementation for domain tag entity
func (*TagRepo) GetAllViews ¶
GetAllViews returns all existing tag views for passed authorId
type TranslationModel ¶
type TranslationModel struct { ID string `bson:"_id"` AuthorID string `bson:"author_id"` CreatedAt time.Time `bson:"created_at"` UpdatedAt time.Time `bson:"updatedAt"` Transcription string `bson:"transcription"` Target string `bson:"target"` Source string `bson:"source"` Example string `bson:"example"` TagIDs []string `bson:"tag_ids"` LangID string `bson:"lang_id"` }
TranslationModel represents mongo translation document
type TranslationRepo ¶
type TranslationRepo struct {
// contains filtered or unexported fields
}
TranslationRepo Mongo DB implementation for domain translation entity
func NewTranslationRepo ¶
func NewTranslationRepo(db *mongo.Database, tagRepo query.TagViewRepository, langRepo query.LangViewRepository) (*TranslationRepo, error)
NewTranslationRepo creates new TranslationRepo
func (*TranslationRepo) Create ¶
func (r *TranslationRepo) Create(t *translation.Translation) error
Create saves new translation to DB
func (*TranslationRepo) Delete ¶
func (r *TranslationRepo) Delete(id, authorID string) error
func (*TranslationRepo) DeleteByAuthorID ¶
func (r *TranslationRepo) DeleteByAuthorID(authorID string) (int, error)
func (*TranslationRepo) ExistByLang ¶
func (r *TranslationRepo) ExistByLang(langID, authorID string) (bool, error)
func (*TranslationRepo) ExistByTag ¶
func (r *TranslationRepo) ExistByTag(tagID, authorID string) (bool, error)
func (*TranslationRepo) Get ¶
func (r *TranslationRepo) Get(id, authorID string) (*translation.Translation, error)
Get performs search request based on translation id and author id parameters and returns domain translation entity
func (*TranslationRepo) GetLastViewsBySourcePart ¶
func (r *TranslationRepo) GetLastViewsBySourcePart(authorID, langID, sourcePart string, pageSize, page int) (query.LastTranslationViews, error)
func (*TranslationRepo) GetLastViewsByTags ¶
func (r *TranslationRepo) GetLastViewsByTags(authorID, langID string, pageSize, page int, tagIds []string) (query.LastTranslationViews, error)
func (*TranslationRepo) GetLastViewsByTargetPart ¶
func (r *TranslationRepo) GetLastViewsByTargetPart(authorID, langID, targetPart string, pageSize, page int) (query.LastTranslationViews, error)
func (*TranslationRepo) GetRandomViews ¶
func (r *TranslationRepo) GetRandomViews(authorID, langID string, tagIds []string, limit int) (query.RandomViews, error)
func (*TranslationRepo) GetView ¶
func (r *TranslationRepo) GetView(id, authorID string) (query.TranslationView, error)
func (*TranslationRepo) Update ¶
func (r *TranslationRepo) Update(t *translation.Translation) error
Update updates already existed translation
type UserModel ¶
type UserModel struct { ID string `bson:"_id"` Name string `bson:"name"` Email string `bson:"email"` Password string `bson:"password"` Role int `bson:"role"` DefaultLangID string `bson:"default_lang_id"` ListOptions ListOptionsModel `bson:"list_options"` }
UserModel represents mongo user document
type UserRepo ¶
type UserRepo struct {
// contains filtered or unexported fields
}
UserRepo Mongo DB implementation for domain user entity
func NewUserRepo ¶
func NewUserRepo(db *mongo.Database, langRepo query.LangViewRepository, roleMapper *query.RoleConverter) (*UserRepo, error)
NewUserRepo creates new UserRepo
func (*UserRepo) GetByEmail ¶
GetByEmail returns User for email