v0.0.142
This commit is contained in:
parent
e89e2c18f2
commit
a4b5f33d15
6
.idea/goext.iml
generated
6
.idea/goext.iml
generated
@ -1,6 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="Go" enabled="true">
|
||||
<buildTags>
|
||||
<option name="goVersion" value="1.19" />
|
||||
</buildTags>
|
||||
</component>
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
|
@ -58,6 +58,10 @@ func (c *Coll[TData]) List(ctx context.Context, filter ct.Filter, pageSize *int,
|
||||
return entities, nextToken, nil
|
||||
}
|
||||
|
||||
type countRes struct {
|
||||
Count int64 `bson:"c"`
|
||||
}
|
||||
|
||||
func (c *Coll[TData]) Count(ctx context.Context, filter ct.Filter) (int64, error) {
|
||||
pipeline := filter.FilterQuery()
|
||||
|
||||
@ -68,12 +72,8 @@ func (c *Coll[TData]) Count(ctx context.Context, filter ct.Filter) (int64, error
|
||||
return 0, err
|
||||
}
|
||||
|
||||
type res struct {
|
||||
Count int64 `bson:"c"`
|
||||
}
|
||||
|
||||
if cursor.Next(ctx) {
|
||||
v := res{}
|
||||
v := countRes{}
|
||||
err = cursor.Decode(&v)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
Loading…
Reference in New Issue
Block a user