pagination optimization
This commit is contained in:
+8
-3
@@ -7,8 +7,8 @@ import (
|
||||
|
||||
// Index represents a MongoDB index
|
||||
type Index struct {
|
||||
Name string `json:"name"`
|
||||
Keys bson.D `json:"keys"`
|
||||
Name string `json:"name"`
|
||||
Keys bson.D `json:"keys"`
|
||||
Options *options.IndexOptionsBuilder `json:"options"`
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ func (i *Index) WithSparse(sparse bool) *Index {
|
||||
return i
|
||||
}
|
||||
|
||||
|
||||
// WithExpireAfterSeconds sets the TTL for the index
|
||||
func (i *Index) WithExpireAfterSeconds(seconds int32) *Index {
|
||||
i.Options.SetExpireAfterSeconds(seconds)
|
||||
@@ -294,6 +293,12 @@ func (pb *PaginationBuilder) SortDesc(field string) *PaginationBuilder {
|
||||
return pb.SortBy(field, "desc")
|
||||
}
|
||||
|
||||
// Projection sets optional MongoDB field projection for Find (e.g. exclude large fields).
|
||||
func (pb *PaginationBuilder) Projection(projection bson.M) *PaginationBuilder {
|
||||
pb.pagination.Projection = projection
|
||||
return pb
|
||||
}
|
||||
|
||||
// Build returns the final pagination options
|
||||
func (pb *PaginationBuilder) Build() Pagination {
|
||||
return pb.pagination
|
||||
|
||||
Reference in New Issue
Block a user