Skip to content

Commit

Permalink
fix: 无稿件时的最大id判断
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Apr 30, 2024
1 parent eccab55 commit 54d9980
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/database/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ func (m *MongoDBManager) GetMaxPostID() (int, error) {
options.FindOne().SetSort(bson.M{"id": -1}),
).Decode(&post)
if err != nil {
if err == mongo.ErrNoDocuments {
return 0, nil
}
return 0, err
}

Expand Down

0 comments on commit 54d9980

Please sign in to comment.