mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-13 18:02:26 +08:00
chore: trash
This commit is contained in:
15
pkg/cache/store/mongodb.go
vendored
15
pkg/cache/store/mongodb.go
vendored
@@ -280,6 +280,21 @@ func (db *mongodb) RecoverArticle(ctx context.Context, id int) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// LoadArticle 查找文章
|
||||
func (db *mongodb) LoadArticle(ctx context.Context, id int) (*model.Article, error) {
|
||||
collection := db.Database(mongoDBName).Collection(collectionArticle)
|
||||
|
||||
filter := bson.M{"id": id}
|
||||
result := collection.FindOne(ctx, filter)
|
||||
err := result.Err()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
article := &model.Article{}
|
||||
err = result.Decode(article)
|
||||
return article, err
|
||||
}
|
||||
|
||||
// LoadAllArticle 读取所有文章
|
||||
func (db *mongodb) LoadAllArticle(ctx context.Context) (model.SortedArticles, error) {
|
||||
collection := db.Database(mongoDBName).Collection(collectionArticle)
|
||||
|
||||
2
pkg/cache/store/store.go
vendored
2
pkg/cache/store/store.go
vendored
@@ -48,6 +48,8 @@ type Store interface {
|
||||
UpdateArticle(ctx context.Context, id int, fields map[string]interface{}) error
|
||||
// RecoverArticle 恢复文章到草稿
|
||||
RecoverArticle(ctx context.Context, id int) error
|
||||
// LoadArticle 查找文章
|
||||
LoadArticle(ctx context.Context, id int) (*model.Article, error)
|
||||
// LoadAllArticle 读取所有文章
|
||||
LoadAllArticle(ctx context.Context) (model.SortedArticles, error)
|
||||
// LoadTrashArticles 读取回收箱
|
||||
|
||||
Reference in New Issue
Block a user