mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-23 06:32:28 +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)
|
||||
|
||||
Reference in New Issue
Block a user