diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e93b61..71646ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,3 +35,5 @@ jobs: bundler-cache: true - name: Run tests run: bundle exec rspec + - name: Run examples + run: bundle exec ruby examples/feed.rb diff --git a/README.md b/README.md index a47fcb2..e1b7d71 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,11 @@ Mongoid extension that enables infinite scrolling for `Mongoid::Criteria` and `M ## Compatibility -This gem supports Mongoid 6, 7 and 8. +This gem supports Mongoid 6, 7, 8 and 9. ## Demo -Check out [shows on artsy.net](http://artsy.net/shows). Keep scrolling down. - -There're also two code samples for Mongoid in [examples](examples). Run `bundle exec ruby examples/feed.rb`. +Take a look at [this example](examples/feed.rb). Try with with `bundle exec ruby examples/feed.rb`. ## The Problem @@ -55,8 +53,10 @@ A sample model. module Feed class Item include Mongoid::Document + field :title, type: String field :position, type: Integer + index({ position: 1, _id: 1 }) end end @@ -73,7 +73,7 @@ Feed::Item.desc(:position).limit(5).scroll do |record, iterator| end ``` -Resume iterating using saved cursor and save the cursor to go backward. +Resume iterating using the saved cursor and save the cursor to go backwards. ```ruby Feed::Item.desc(:position).limit(5).scroll(saved_iterator.next_cursor) do |record, iterator| diff --git a/examples/feed.rb b/examples/feed.rb index 6c617f5..dc58de5 100644 --- a/examples/feed.rb +++ b/examples/feed.rb @@ -38,7 +38,7 @@ class Item next_cursor = nil Feed::Item.asc(:position).limit(scroll_by).scroll(current_cursor) do |item, cursor| puts "#{item.position}: #{item.title}" - next_cursor = cursor + next_cursor = cursor.next_cursor total_shown += 1 end break unless next_cursor