Skip to content

Commit d9b2e48

Browse files
committed
query: allow to always request the size alongside KeysOnly, allow impl to always return the size if no perf cost
1 parent f860a4a commit d9b2e48

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

autobatch/autobatch.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
dsq "github.com/ipfs/go-datastore/query"
99
)
1010

11-
// Datastore implements a go-datatsore.
11+
// Datastore implements a go-datastore.
1212
type Datastore struct {
1313
child ds.Batching
1414

query/query.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,18 @@ type Query struct {
6565
Offset int // skip given number of results
6666
KeysOnly bool // return only keys.
6767
ReturnExpirations bool // return expirations (see TTLDatastore)
68+
ReturnsSize bool // always return sizes. If not set, datastore impl can return
69+
// // it anyway if it doesn't involve a performance cost. If KeysOnly
70+
// // is not set, Size should always be set.
6871
}
6972

7073
// Entry is a query result entry.
7174
type Entry struct {
7275
Key string // cant be ds.Key because circular imports ...!!!
73-
Size int // Might be zero if the datastore doesn't support listing the size with KeysOnly
7476
Value []byte // Will be nil if KeysOnly has been passed.
7577
Expiration time.Time // Entry expiration timestamp if requested and supported (see TTLDatastore).
78+
Size int // Might be -1 if the datastore doesn't support listing the size with KeysOnly
79+
// // or if ReturnsSizes is not set
7680
}
7781

7882
// Result is a special entry that includes an error, so that the client

0 commit comments

Comments
 (0)