post

package
v1.2.34 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: GPL-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const CollectionName = "post"
View Source
const (
	OfficialFlag = 1 << 0
)

Variables

This section is empty.

Functions

func MakeBsonFilter

func MakeBsonFilter(options *FilterOptions) bson.M

Types

type BaseFilter

type BaseFilter struct {
	MustFlags    *Flag
	MustNotFlags *Flag
	*FilterOptions
}

func (*BaseFilter) CheckOnlyOfficial

func (f *BaseFilter) CheckOnlyOfficial()

type EsMapper

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

func (*EsMapper) CountWithQuery

func (m *EsMapper) CountWithQuery(ctx context.Context, query []types.Query, fopts *FilterOptions) (int64, error)

func (*EsMapper) Search

func (m *EsMapper) Search(ctx context.Context, query []types.Query, fopts *FilterOptions, popts *pagination.PaginationOptions, sorter esp.EsCursor) ([]*Post, int64, error)

type FilterOptions

type FilterOptions struct {
	OnlyUserId   *string
	OnlyOfficial *bool
}

type Flag

type Flag int64

func (*Flag) GetFlag

func (f *Flag) GetFlag(flag Flag) bool

func (*Flag) SetFlag

func (f *Flag) SetFlag(flag Flag, b bool) *Flag

type IEsMapper

type IEsMapper interface {
	Search(ctx context.Context, query []types.Query, fopts *FilterOptions, popts *pagination.PaginationOptions, sorter esp.EsCursor) ([]*Post, int64, error)
	CountWithQuery(ctx context.Context, query []types.Query, fopts *FilterOptions) (int64, error)
}

func NewEsMapper

func NewEsMapper(config *config.Config) IEsMapper

type IMongoMapper

type IMongoMapper interface {
	Insert(ctx context.Context, data *Post) error
	FindOne(ctx context.Context, id string) (*Post, error)
	Update(ctx context.Context, data *Post) error
	Delete(ctx context.Context, id string) error
	FindMany(ctx context.Context, fopts *FilterOptions, popts *pagination.PaginationOptions, sorter mongop.MongoCursor) ([]*Post, error)
	Count(ctx context.Context, fopts *FilterOptions) (int64, error)
	FindManyAndCount(ctx context.Context, fopts *FilterOptions, popts *pagination.PaginationOptions, sorter mongop.MongoCursor) ([]*Post, int64, error)
	UpdateFlags(ctx context.Context, id string, flags map[Flag]bool) error
}

func NewMongoMapper

func NewMongoMapper(config *config.Config) IMongoMapper

type MongoFilter

type MongoFilter struct {
	*BaseFilter
	// contains filtered or unexported fields
}

func (*MongoFilter) CheckFlags

func (f *MongoFilter) CheckFlags()

func (*MongoFilter) CheckOnlyUserId

func (f *MongoFilter) CheckOnlyUserId()

type MongoMapper

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

func (*MongoMapper) Count

func (m *MongoMapper) Count(ctx context.Context, filter *FilterOptions) (int64, error)

func (*MongoMapper) Delete

func (m *MongoMapper) Delete(ctx context.Context, id string) error

func (*MongoMapper) FindMany

func (m *MongoMapper) FindMany(ctx context.Context, fopts *FilterOptions, popts *pagination.PaginationOptions, sorter mongop.MongoCursor) ([]*Post, error)

func (*MongoMapper) FindManyAndCount

func (m *MongoMapper) FindManyAndCount(ctx context.Context, fopts *FilterOptions, popts *pagination.PaginationOptions, sorter mongop.MongoCursor) ([]*Post, int64, error)

func (*MongoMapper) FindOne

func (m *MongoMapper) FindOne(ctx context.Context, id string) (*Post, error)

func (*MongoMapper) Insert

func (m *MongoMapper) Insert(ctx context.Context, data *Post) error

func (*MongoMapper) Update

func (m *MongoMapper) Update(ctx context.Context, data *Post) error

func (*MongoMapper) UpdateFlags

func (m *MongoMapper) UpdateFlags(ctx context.Context, id string, flags map[Flag]bool) error

type Post

type Post struct {
	ID       primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
	Title    string             `bson:"title,omitempty" `
	Text     string             `bson:"text,omitempty"`
	CoverUrl string             `bson:"coverUrl,omitempty"`
	Tags     []string           `bson:"tags,omitempty"`
	UserId   string             `bson:"userId,omitempty"`
	Flags    *Flag              `bson:"flags,omitempty"`
	UpdateAt time.Time          `bson:"updateAt,omitempty"`
	CreateAt time.Time          `bson:"createAt,omitempty"`
	// 仅ES查询时使用
	Score_ float64 `bson:"_score,omitempty" json:"_score,omitempty"`
}

Jump to

Keyboard shortcuts

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