Fix broken filtering through discriminator
This commit is contained in:
11
find.go
11
find.go
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"git.gsuntres.com/general/commons"
|
||||
)
|
||||
|
||||
// Find is used to fetch the first page of data.
|
||||
@@ -89,10 +90,14 @@ func (c *MongoClient) FindOffset(ctx context.Context, database, name string, fil
|
||||
|
||||
finalLimit := max(limit, c.Limit)
|
||||
|
||||
if err := c.DiscriminatorCheckAndApplyToFilter(ctx, name, filter); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
f := Mongofy(&Query{
|
||||
Filter: filter,
|
||||
})
|
||||
|
||||
|
||||
pipeline := BuildPaginationPipeline(offset, finalLimit, f, nil)
|
||||
|
||||
// 2. Query
|
||||
@@ -116,8 +121,8 @@ func (c *MongoClient) FindOffset(ctx context.Context, database, name string, fil
|
||||
|
||||
var totalValue any
|
||||
if len(metadata) != 0 {
|
||||
metadataRoot := metadata[0].(bson.M)
|
||||
totalValue = metadataRoot["total"]
|
||||
metadataRoot := metadata[0].(bson.D)
|
||||
totalValue, _ = commons.BsonDGetAny(metadataRoot, "total")
|
||||
}
|
||||
|
||||
var total int64
|
||||
|
||||
Reference in New Issue
Block a user