From f8c722fbed03a92d3ee093da6b7f42582fb97509 Mon Sep 17 00:00:00 2001 From: Preetam Jinka Date: Sat, 17 Sep 2016 12:56:45 -0400 Subject: [PATCH] allow cursors for empty collections; #13 --- cursor.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cursor.go b/cursor.go index 6391e83..926a98b 100644 --- a/cursor.go +++ b/cursor.go @@ -1,7 +1,5 @@ package lm2 -import "errors" - // Cursor represents a snapshot cursor. type Cursor struct { collection *Collection @@ -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)