We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 550d401 + dfd3d88 commit 51fbfaeCopy full SHA for 51fbfae
1 file changed
backend/internal/extension/repo/extension.go
@@ -2,6 +2,7 @@ package repo
2
3
import (
4
"context"
5
+ "fmt"
6
7
"entgo.io/ent/dialect/sql"
8
@@ -22,11 +23,18 @@ func NewExtensionRepo(db *db.Client) domain.ExtensionRepo {
22
23
24
// Latest implements domain.ExtensionRepo.
25
func (e *ExtensionRepo) Latest(ctx context.Context) (*db.Extension, error) {
- return e.db.Extension.
26
+ es, err := e.db.Extension.
27
Query().
28
Order(extension.ByCreatedAt(sql.OrderDesc())).
29
Limit(1).
- Only(ctx)
30
+ All(ctx)
31
+ if err != nil {
32
+ return nil, err
33
+ }
34
+ if len(es) == 0 {
35
+ return nil, fmt.Errorf("extension not found")
36
37
+ return es[0], nil
38
}
39
40
// Save implements domain.ExtensionRepo.
0 commit comments