Skip to content

Commit

Permalink
fix(server): item search mongo pipeline (#1097)
Browse files Browse the repository at this point in the history
imp
  • Loading branch information
yk-eukarya committed Oct 1, 2024
1 parent 7d279ea commit 018d3c1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions server/internal/infrastructure/mongo/item_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package mongo
import (
"context"
"fmt"
"regexp"
"time"

"github.com/reearth/reearth-cms/server/pkg/id"
"github.com/reearth/reearth-cms/server/pkg/item"
"github.com/reearth/reearth-cms/server/pkg/item/view"
Expand All @@ -16,8 +19,6 @@ import (
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.opencensus.io/trace"
"regexp"
"time"
)

func (r *Item) Search(ctx context.Context, sp schema.Package, query *item.Query, pagination *usecasex.Pagination) (item.VersionedList, *usecasex.PageInfo, error) {
Expand Down Expand Up @@ -203,15 +204,13 @@ func lookupAssetField(f schema.Field) []any {
"foreignField": "id",
"as": "__temp.&" + f.ID().String(),
"pipeline": []bson.M{
{
"$limit": 1,
},
{"$limit": 1},
{"$project": bson.M{"filename": 1}},
},
},
},
bson.M{
"$set": bson.M{
//"__temp.fields." + f.ID().String(): bson.M{"$arrayElemAt": bson.A{"$__temp.&" + f.ID().String() + ".filename", 0}},
"__temp.fields." + f.ID().String(): "$__temp.&" + f.ID().String() + ".filename",
},
},
Expand Down

0 comments on commit 018d3c1

Please sign in to comment.