Skip to content

Instantly share code, notes, and snippets.

@cihangir
Created September 17, 2013 12:42
Show Gist options
  • Save cihangir/6593841 to your computer and use it in GitHub Desktop.
Save cihangir/6593841 to your computer and use it in GitHub Desktop.
iter mgo
iter := collection.Find(nil).Sort("$natural").Tail(5 * time.Second)
for {
for iter.Next(&result) {
fmt.Println(result.Id)
lastId = result.Id
}
if err := iter.Close(); err != nil {
return err
}
if iter.Timeout() {
continue
}
query := collection.Find(bson.M{"_id": bson.M{"$gt": lastId}})
iter = query.Sort("$natural").Tail(5 * time.Second)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment