Skip to content

Commit

Permalink
Merge pull request #14 from Preetam/13-empty-collection-cursor
Browse files Browse the repository at this point in the history
Allow cursors for empty collections
  • Loading branch information
Preetam authored Sep 17, 2016
2 parents bd8d701 + f8c722f commit 4a47593
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cursor.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package lm2

import "errors"

// Cursor represents a snapshot cursor.
type Cursor struct {
collection *Collection
Expand All @@ -16,7 +14,12 @@ func (c *Collection) NewCursor() (*Cursor, error) {
c.metaLock.RLock()
defer c.metaLock.RUnlock()
if c.Head == 0 {
return nil, errors.New("lm2: no keys")
return &Cursor{
collection: c,
current: nil,
first: false,
snapshot: c.LastCommit,
}, nil
}

head, err := c.readRecord(c.Head)
Expand Down

0 comments on commit 4a47593

Please sign in to comment.