Documentation
¶
Index ¶
- func SetLogger(l Logger)
- type ContextLogger
- type DB
- func (d *DB) Close()
- func (d *DB) Collections(ctx context.Context, parent string) (keyup.CollectionIterator, error)
- func (d *DB) Count(ctx context.Context, prefix string, contains string) (int, error)
- func (d *DB) Create(ctx context.Context, path string, b []byte) error
- func (d *DB) Delete(ctx context.Context, path string) (bool, error)
- func (d *DB) DeleteAll(ctx context.Context, parent string) error
- func (d *DB) Documents(ctx context.Context, parent string, opts *keyup.DocumentsOpts) (keyup.DocumentIterator, error)
- func (d *DB) Exists(ctx context.Context, path string) (bool, error)
- func (d *DB) Get(ctx context.Context, path string) (*keyup.Document, error)
- func (d *DB) GetAll(ctx context.Context, paths []string) ([]*keyup.Document, error)
- func (d *DB) IsOpen() bool
- func (d *DB) Last(ctx context.Context, prefix string) (*keyup.Document, error)
- func (d *DB) Now() time.Time
- func (d *DB) OpenAtPath(path string) error
- func (d *DB) Set(ctx context.Context, path string, b []byte) error
- func (d *DB) SetTimeNow(nowFn func() time.Time)
- type LogLevel
- type Logger
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContextLogger ¶
type ContextLogger interface { Debugf(ctx context.Context, format string, args ...interface{}) Infof(ctx context.Context, format string, args ...interface{}) Warningf(ctx context.Context, format string, args ...interface{}) Errorf(ctx context.Context, format string, args ...interface{}) }
ContextLogger interface used in this package with request context.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is leveldb implementation of keyup.DocumentStore
func (*DB) Collections ¶
Collections ...
func (*DB) Count ¶
Count returns number of docs in a collection with prefix and filter. This iterates over the prefixed docs to count them.
func (*DB) Create ¶
Create entry.
Example ¶
db := NewDB() defer db.Close() if err := db.OpenAtPath("/tmp/keyup.db"); err != nil { log.Fatal(err) } if err := db.Create(context.TODO(), "/test/1", []byte{0x01, 0x02, 0x03}); err != nil { log.Fatal(err) }
Output:
func (*DB) Documents ¶
func (d *DB) Documents(ctx context.Context, parent string, opts *keyup.DocumentsOpts) (keyup.DocumentIterator, error)
Documents ...
func (*DB) Get ¶
Get entry at path.
Example ¶
db := NewDB() defer db.Close() dir, err := ioutil.TempDir("", "keyup") if err != nil { log.Fatal(err) } path := filepath.Join(dir, "keyup.db") if err := db.OpenAtPath(path); err != nil { log.Fatal(err) } if err := db.Create(context.TODO(), "/test/1", []byte{0x01, 0x02, 0x03}); err != nil { log.Fatal(err) } doc, err := db.Get(context.TODO(), "/test/1") if err != nil { log.Fatal(err) } fmt.Printf("%s\n", doc.Path) fmt.Printf("%v\n", doc.Data)
Output: /test/1 [1 2 3]
func (*DB) OpenAtPath ¶
OpenAtPath opens db located at path
Example ¶
db := NewDB() defer db.Close() if err := db.OpenAtPath("/tmp/keyup.db"); err != nil { log.Fatal(err) }
Output:
Click to show internal directories.
Click to hide internal directories.