mongoid-scroll 1.0.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +26 -7
- data/.github/workflows/danger-comment.yml +9 -0
- data/.github/workflows/danger.yml +9 -15
- data/.gitignore +1 -0
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +153 -35
- data/CHANGELOG.md +22 -5
- data/Dangerfile +5 -1
- data/Gemfile +16 -8
- data/README.md +27 -38
- data/RELEASING.md +31 -50
- data/Rakefile +3 -3
- data/UPGRADING.md +21 -1
- data/examples/{mongoid_scroll_feed.rb → feed.rb} +4 -3
- data/lib/config/locales/en.yml +4 -1
- data/lib/mongoid/criteria/scrollable/fields.rb +6 -0
- data/lib/mongoid/criteria/scrollable/iterator.rb +19 -0
- data/lib/mongoid/criteria/scrollable.rb +29 -9
- data/lib/mongoid/scroll/base64_encoded_cursor.rb +8 -6
- data/lib/mongoid/scroll/base_cursor.rb +12 -11
- data/lib/mongoid/scroll/cursor.rb +5 -5
- data/lib/mongoid/scroll/errors/base.rb +4 -4
- data/lib/mongoid/scroll/errors/mismatched_sort_fields_error.rb +1 -3
- data/lib/mongoid/scroll/errors/multiple_sort_fields_error.rb +1 -3
- data/lib/mongoid/scroll/errors/unsupported_type_error.rb +11 -0
- data/lib/mongoid/scroll/errors.rb +1 -0
- data/lib/mongoid/scroll/version.rb +1 -1
- data/lib/mongoid-scroll.rb +1 -2
- data/mongoid-scroll.gemspec +3 -3
- data/spec/mongoid/base64_encoded_cursor_spec.rb +148 -77
- data/spec/mongoid/criteria_spec.rb +139 -37
- data/spec/mongoid/cursor_spec.rb +112 -63
- data/spec/mongoid/scroll_spec.rb +1 -1
- data/spec/spec_helper.rb +14 -3
- data/spec/support/feed/embedded_item.rb +2 -0
- data/spec/support/feed/item.rb +1 -1
- metadata +13 -26
- data/examples/mongo_ruby_driver_scroll_feed.rb +0 -45
- data/lib/mongo/scrollable.rb +0 -39
- data/spec/mongo/collection_view_spec.rb +0 -143
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d9e2af0b05c25202ce0f2c1e87b760a0d41c7f534c0675f90a513e249949b503
|
|
4
|
+
data.tar.gz: 83b648b0c1c8073ef6cf3dccdaa071051784f95b6db85ecddc079e30706e512a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9582fb4fb8da92db5d65fbb076578bb0ff732e2073c7e0f1c095deee6fe399939712917752ac4f656ea81937f986d0475d622f3193fbeef56f35a1e4b306cc53
|
|
7
|
+
data.tar.gz: a245b4f08c1546e92b9ed1bc8d260391a935ad3d2079f5d7eaa8effe0954da187b1cf6f12846bc9aefe05a4e2475aeda4fc952ef611e209e3a637ce99d0bf908
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -5,10 +5,9 @@ jobs:
|
|
|
5
5
|
test:
|
|
6
6
|
runs-on: ubuntu-latest
|
|
7
7
|
strategy:
|
|
8
|
+
fail-fast: false
|
|
8
9
|
matrix:
|
|
9
10
|
entry:
|
|
10
|
-
- { ruby: '2.6', mongodb: '4.4', mongoid: '5' }
|
|
11
|
-
- { ruby: '3.2', mongodb: '6.0', mongoid: '5' }
|
|
12
11
|
- { ruby: '2.7', mongodb: '4.4', mongoid: '6' }
|
|
13
12
|
- { ruby: '2.7', mongodb: '4.4', mongoid: '7' }
|
|
14
13
|
- { ruby: '3.0', mongodb: '4.4', mongoid: '6' }
|
|
@@ -18,15 +17,26 @@ jobs:
|
|
|
18
17
|
- { ruby: '3.1', mongodb: '4.4', mongoid: '8' }
|
|
19
18
|
- { ruby: '3.2', mongodb: '5.0', mongoid: '8' }
|
|
20
19
|
- { ruby: '3.2', mongodb: '6.0', mongoid: '8' }
|
|
20
|
+
- { ruby: '3.2', mongodb: '7.0', mongoid: '8' }
|
|
21
|
+
- { ruby: '3.3', mongodb: '6.0', mongoid: '9' }
|
|
22
|
+
- { ruby: '3.3', mongodb: '7.0', mongoid: '9' }
|
|
23
|
+
- { ruby: '3.4', mongodb: '8.0', mongoid: '9' }
|
|
24
|
+
- { ruby: '4.0', mongodb: '8.0', mongoid: '9', coverage: 'true' }
|
|
21
25
|
name: test (ruby=${{ matrix.entry.ruby }}, mongodb=${{ matrix.entry.mongodb }}), mongoid=${{ matrix.entry.mongoid }})
|
|
22
26
|
env:
|
|
23
27
|
MONGOID_VERSION: ${{ matrix.entry.mongoid }}
|
|
28
|
+
COVERAGE: ${{ matrix.entry.coverage }}
|
|
29
|
+
services:
|
|
30
|
+
mongodb:
|
|
31
|
+
image: mongo:${{ matrix.entry.mongodb }}
|
|
32
|
+
ports: ['27017:27017']
|
|
33
|
+
options: >-
|
|
34
|
+
--health-cmd "mongosh --quiet --eval 'db.adminCommand({ping: 1})' || mongo --quiet --eval 'db.adminCommand({ping: 1})'"
|
|
35
|
+
--health-interval 10s
|
|
36
|
+
--health-timeout 5s
|
|
37
|
+
--health-retries 10
|
|
24
38
|
steps:
|
|
25
|
-
-
|
|
26
|
-
uses: supercharge/mongodb-github-action@1.8.0
|
|
27
|
-
with:
|
|
28
|
-
mongodb-version: ${{ matrix.entry.mongodb }}
|
|
29
|
-
- uses: actions/checkout@v3
|
|
39
|
+
- uses: actions/checkout@v7
|
|
30
40
|
- name: Set up Ruby
|
|
31
41
|
uses: ruby/setup-ruby@v1
|
|
32
42
|
with:
|
|
@@ -34,3 +44,12 @@ jobs:
|
|
|
34
44
|
bundler-cache: true
|
|
35
45
|
- name: Run tests
|
|
36
46
|
run: bundle exec rspec
|
|
47
|
+
- name: Run examples
|
|
48
|
+
run: bundle exec ruby examples/feed.rb
|
|
49
|
+
- name: Report Coverage
|
|
50
|
+
if: ${{ matrix.entry.coverage == 'true' }}
|
|
51
|
+
uses: coverallsapp/github-action@v2
|
|
52
|
+
with:
|
|
53
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
54
|
+
file: coverage/.resultset.json
|
|
55
|
+
format: simplecov
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
name:
|
|
2
|
-
on:
|
|
1
|
+
name: Danger
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
types: [opened, reopened, edited, synchronize]
|
|
3
5
|
jobs:
|
|
4
6
|
danger:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- uses: ruby/setup-ruby@v1
|
|
11
|
-
with:
|
|
12
|
-
ruby-version: 2.7
|
|
13
|
-
bundler-cache: true
|
|
14
|
-
- run: |
|
|
15
|
-
# Personal access token for dangerpr-bot - public, but base64 encoded to avoid tripping up GitHub
|
|
16
|
-
TOKEN=$(echo -n Z2hwX0xNQ3VmanBFeTBvYkZVTWh6NVNqVFFBOEUxU25abzBqRUVuaAo= | base64 --decode)
|
|
17
|
-
DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
|
|
7
|
+
uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@v0.1.0
|
|
8
|
+
with:
|
|
9
|
+
ruby-version: '3.4'
|
|
10
|
+
bundler-cache: true
|
|
11
|
+
secrets: inherit
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
|
@@ -1,59 +1,159 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2024-09-07 13:11:15 UTC using RuboCop version 1.66.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
8
|
|
|
9
|
-
# Offense count:
|
|
10
|
-
# Configuration parameters: Include.
|
|
11
|
-
# Include:
|
|
12
|
-
|
|
9
|
+
# Offense count: 1
|
|
10
|
+
# Configuration parameters: Severity, Include.
|
|
11
|
+
# Include: **/*.gemspec
|
|
12
|
+
Gemspec/RequiredRubyVersion:
|
|
13
13
|
Exclude:
|
|
14
|
-
- '
|
|
14
|
+
- 'mongoid-scroll.gemspec'
|
|
15
15
|
|
|
16
|
-
# Offense count:
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
# Offense count: 1
|
|
17
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
18
|
+
Lint/NonDeterministicRequireOrder:
|
|
19
|
+
Exclude:
|
|
20
|
+
- 'spec/spec_helper.rb'
|
|
19
21
|
|
|
20
|
-
# Offense count:
|
|
21
|
-
# Configuration parameters:
|
|
22
|
-
Metrics/
|
|
23
|
-
Max:
|
|
22
|
+
# Offense count: 7
|
|
23
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
|
24
|
+
Metrics/AbcSize:
|
|
25
|
+
Max: 28
|
|
24
26
|
|
|
25
27
|
# Offense count: 1
|
|
26
|
-
# Configuration parameters: CountComments.
|
|
28
|
+
# Configuration parameters: CountComments, CountAsOne.
|
|
27
29
|
Metrics/ClassLength:
|
|
28
|
-
Max:
|
|
30
|
+
Max: 108
|
|
29
31
|
|
|
30
32
|
# Offense count: 5
|
|
33
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
31
34
|
Metrics/CyclomaticComplexity:
|
|
32
35
|
Max: 13
|
|
33
36
|
|
|
34
|
-
# Offense count: 153
|
|
35
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
|
36
|
-
# URISchemes: http, https
|
|
37
|
-
Metrics/LineLength:
|
|
38
|
-
Max: 252
|
|
39
|
-
|
|
40
37
|
# Offense count: 7
|
|
41
|
-
# Configuration parameters: CountComments.
|
|
38
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
42
39
|
Metrics/MethodLength:
|
|
43
|
-
Max:
|
|
40
|
+
Max: 24
|
|
44
41
|
|
|
45
|
-
# Offense count:
|
|
42
|
+
# Offense count: 3
|
|
43
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
46
44
|
Metrics/PerceivedComplexity:
|
|
47
|
-
Max:
|
|
45
|
+
Max: 13
|
|
46
|
+
|
|
47
|
+
# Offense count: 1
|
|
48
|
+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
|
49
|
+
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
|
|
50
|
+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
|
51
|
+
Naming/FileName:
|
|
52
|
+
Exclude:
|
|
53
|
+
- 'Rakefile.rb'
|
|
54
|
+
- 'lib/mongoid-scroll.rb'
|
|
55
|
+
|
|
56
|
+
# Offense count: 3
|
|
57
|
+
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
|
|
58
|
+
# SupportedStyles: snake_case, normalcase, non_integer
|
|
59
|
+
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
|
|
60
|
+
Naming/VariableNumber:
|
|
61
|
+
Exclude:
|
|
62
|
+
- 'spec/mongoid/criteria_spec.rb'
|
|
63
|
+
|
|
64
|
+
# Offense count: 34
|
|
65
|
+
# Configuration parameters: Prefixes, AllowedPatterns.
|
|
66
|
+
# Prefixes: when, with, without
|
|
67
|
+
RSpec/ContextWording:
|
|
68
|
+
Exclude:
|
|
69
|
+
- 'spec/mongoid/base64_encoded_cursor_spec.rb'
|
|
70
|
+
- 'spec/mongoid/criteria_spec.rb'
|
|
71
|
+
- 'spec/mongoid/cursor_spec.rb'
|
|
72
|
+
|
|
73
|
+
# Offense count: 34
|
|
74
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
75
|
+
# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
|
|
76
|
+
# SupportedStyles: described_class, explicit
|
|
77
|
+
RSpec/DescribedClass:
|
|
78
|
+
Exclude:
|
|
79
|
+
- 'spec/mongoid/base64_encoded_cursor_spec.rb'
|
|
80
|
+
- 'spec/mongoid/cursor_spec.rb'
|
|
81
|
+
|
|
82
|
+
# Offense count: 17
|
|
83
|
+
# Configuration parameters: CountAsOne.
|
|
84
|
+
RSpec/ExampleLength:
|
|
85
|
+
Max: 18
|
|
86
|
+
|
|
87
|
+
# Offense count: 3
|
|
88
|
+
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
|
|
89
|
+
RSpec/IndexedLet:
|
|
90
|
+
Exclude:
|
|
91
|
+
- 'spec/mongoid/criteria_spec.rb'
|
|
92
|
+
|
|
93
|
+
# Offense count: 2
|
|
94
|
+
# Configuration parameters: AssignmentOnly.
|
|
95
|
+
RSpec/InstanceVariable:
|
|
96
|
+
Exclude:
|
|
97
|
+
- 'spec/mongoid/criteria_spec.rb'
|
|
48
98
|
|
|
49
99
|
# Offense count: 11
|
|
100
|
+
RSpec/MultipleExpectations:
|
|
101
|
+
Max: 4
|
|
102
|
+
|
|
103
|
+
# Offense count: 4
|
|
104
|
+
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
|
|
105
|
+
# SupportedStyles: always, named_only
|
|
106
|
+
RSpec/NamedSubject:
|
|
107
|
+
Exclude:
|
|
108
|
+
- 'spec/mongoid/criteria_spec.rb'
|
|
109
|
+
|
|
110
|
+
# Offense count: 3
|
|
111
|
+
# Configuration parameters: AllowedGroups.
|
|
112
|
+
RSpec/NestedGroups:
|
|
113
|
+
Max: 4
|
|
114
|
+
|
|
115
|
+
# Offense count: 3
|
|
116
|
+
# Configuration parameters: AllowedPatterns.
|
|
117
|
+
# AllowedPatterns: ^expect_, ^assert_
|
|
118
|
+
RSpec/NoExpectationExample:
|
|
119
|
+
Exclude:
|
|
120
|
+
- 'spec/mongoid/base64_encoded_cursor_spec.rb'
|
|
121
|
+
|
|
122
|
+
# Offense count: 4
|
|
123
|
+
RSpec/RepeatedDescription:
|
|
124
|
+
Exclude:
|
|
125
|
+
- 'spec/mongoid/base64_encoded_cursor_spec.rb'
|
|
126
|
+
|
|
127
|
+
# Offense count: 4
|
|
128
|
+
RSpec/RepeatedExample:
|
|
129
|
+
Exclude:
|
|
130
|
+
- 'spec/mongoid/base64_encoded_cursor_spec.rb'
|
|
131
|
+
|
|
132
|
+
# Offense count: 3
|
|
133
|
+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
|
|
134
|
+
# Include: **/*_spec.rb
|
|
135
|
+
RSpec/SpecFilePathFormat:
|
|
136
|
+
Exclude:
|
|
137
|
+
- '**/spec/routing/**/*'
|
|
138
|
+
- 'spec/mongoid/base64_encoded_cursor_spec.rb'
|
|
139
|
+
- 'spec/mongoid/cursor_spec.rb'
|
|
140
|
+
- 'spec/mongoid/scroll_spec.rb'
|
|
141
|
+
|
|
142
|
+
# Offense count: 1
|
|
143
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
144
|
+
Rake/Desc:
|
|
145
|
+
Exclude:
|
|
146
|
+
- 'Rakefile'
|
|
147
|
+
|
|
148
|
+
# Offense count: 12
|
|
149
|
+
# Configuration parameters: AllowedConstants.
|
|
50
150
|
Style/Documentation:
|
|
51
151
|
Exclude:
|
|
52
152
|
- 'spec/**/*'
|
|
53
153
|
- 'test/**/*'
|
|
54
|
-
- 'examples/
|
|
55
|
-
- 'lib/mongo/scrollable.rb'
|
|
154
|
+
- 'examples/feed.rb'
|
|
56
155
|
- 'lib/mongoid/criteria/scrollable.rb'
|
|
156
|
+
- 'lib/mongoid/criteria/scrollable/iterator.rb'
|
|
57
157
|
- 'lib/mongoid/scroll/base_cursor.rb'
|
|
58
158
|
- 'lib/mongoid/scroll/cursor.rb'
|
|
59
159
|
- 'lib/mongoid/scroll/errors/base.rb'
|
|
@@ -62,22 +162,40 @@ Style/Documentation:
|
|
|
62
162
|
- 'lib/mongoid/scroll/errors/multiple_sort_fields_error.rb'
|
|
63
163
|
- 'lib/mongoid/scroll/errors/no_such_field_error.rb'
|
|
64
164
|
- 'lib/mongoid/scroll/errors/unsupported_field_type_error.rb'
|
|
165
|
+
- 'lib/mongoid/scroll/errors/unsupported_type_error.rb'
|
|
65
166
|
|
|
66
|
-
# Offense count:
|
|
67
|
-
#
|
|
68
|
-
#
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
167
|
+
# Offense count: 34
|
|
168
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
169
|
+
# Configuration parameters: EnforcedStyle.
|
|
170
|
+
# SupportedStyles: always, always_true, never
|
|
171
|
+
Style/FrozenStringLiteralComment:
|
|
172
|
+
Enabled: false
|
|
72
173
|
|
|
73
174
|
# Offense count: 1
|
|
175
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
74
176
|
Style/MultilineTernaryOperator:
|
|
75
177
|
Exclude:
|
|
76
178
|
- 'lib/mongoid/scroll/cursor.rb'
|
|
77
179
|
|
|
78
180
|
# Offense count: 3
|
|
79
|
-
#
|
|
80
|
-
# Configuration parameters:
|
|
181
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
182
|
+
# Configuration parameters: AllowedCompactTypes.
|
|
81
183
|
# SupportedStyles: compact, exploded
|
|
82
184
|
Style/RaiseArgs:
|
|
83
185
|
EnforcedStyle: compact
|
|
186
|
+
|
|
187
|
+
# Offense count: 2
|
|
188
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
189
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
|
|
190
|
+
# AllowedMethods: present?, blank?, presence, try, try!
|
|
191
|
+
Style/SafeNavigation:
|
|
192
|
+
Exclude:
|
|
193
|
+
- 'lib/mongoid/scroll/errors/mismatched_sort_fields_error.rb'
|
|
194
|
+
- 'lib/mongoid/scroll/errors/multiple_sort_fields_error.rb'
|
|
195
|
+
|
|
196
|
+
# Offense count: 36
|
|
197
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
198
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
|
199
|
+
# URISchemes: http, https
|
|
200
|
+
Layout/LineLength:
|
|
201
|
+
Max: 252
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
### 2.0.1 (2026/10/15)
|
|
2
|
+
|
|
3
|
+
* [#48](https://github.com/mongoid/mongoid-scroll/issues/48): Raise `NoSuchFieldError` when a sort or cursor refers to a field no longer defined on the model - [@dblock](https://github.com/dblock).
|
|
4
|
+
* [#51](https://github.com/mongoid/mongoid-scroll/pull/51): Report SimpleCov coverage to Coveralls once per build without duplicate gem uploads and refresh CI and coverage badges - [@dblock](https://github.com/dblock).
|
|
5
|
+
* [#50](https://github.com/mongoid/mongoid-scroll/pull/50): Modernize CI through Ruby 4.0, Mongoid 9 and MongoDB 8; fix Mongoid 9 dependency selection, database cleaner compatibility and invalid Danger workflow references - [@dblock](https://github.com/dblock).
|
|
6
|
+
* [#49](https://github.com/mongoid/mongoid-scroll/pull/49): Migrate Danger to danger-pr-comment workflow - [@dblock](https://github.com/dblock).
|
|
7
|
+
|
|
8
|
+
### 2.0.0 (2024/09/07)
|
|
9
|
+
|
|
10
|
+
* [#38](https://github.com/mongoid/mongoid-scroll/pull/38): Add `previous_cursor` - [@GCorbel](https://github.com/GCorbel).
|
|
11
|
+
* [#42](https://github.com/mongoid/mongoid-scroll/pull/42): Add `first_cursor` - [@GCorbel](https://github.com/GCorbel).
|
|
12
|
+
* [#43](https://github.com/mongoid/mongoid-scroll/pull/43): Add `current_cursor` - [@GCorbel](https://github.com/GCorbel).
|
|
13
|
+
* [#44](https://github.com/mongoid/mongoid-scroll/pull/44): Drop support for Mogoid 5 and Mongo Ruby Driver - [@dblock](https://github.com/dblock).
|
|
14
|
+
* [#45](https://github.com/mongoid/mongoid-scroll/pull/45): Add support for Mogoid 9 - [@dblock](https://github.com/dblock).
|
|
15
|
+
* [#46](https://github.com/mongoid/mongoid-scroll/pull/46): Upgrade RuboCop to 1.66.1 - [@dblock](https://github.com/dblock).
|
|
16
|
+
* [#47](https://github.com/mongoid/mongoid-scroll/pull/47): Add code coverage - [@dblock](https://github.com/dblock).
|
|
17
|
+
|
|
1
18
|
### 1.0.1 (2023/03/15)
|
|
2
19
|
|
|
3
20
|
* [#36](https://github.com/mongoid/mongoid-scroll/pull/36): Keep millisecond precision on time fields - [@FabienChaynes](https://github.com/FabienChaynes).
|
|
@@ -9,8 +26,8 @@
|
|
|
9
26
|
* [#29](https://github.com/mongoid/mongoid-scroll/pull/29): Add ability to include the current record to the cursor - [@FabienChaynes](https://github.com/FabienChaynes).
|
|
10
27
|
* [#30](https://github.com/mongoid/mongoid-scroll/pull/30): Prevent discrepancy between the original sort and the cursor sort - [@FabienChaynes](https://github.com/FabienChaynes).
|
|
11
28
|
* [#32](https://github.com/mongoid/mongoid-scroll/pull/32): Add Base64 serialization for cursors - [@FabienChaynes](https://github.com/FabienChaynes).
|
|
12
|
-
* [#33](https://github.com/mongoid/mongoid-scroll/pull/33):
|
|
13
|
-
* [#34](https://github.com/mongoid/mongoid-scroll/pull/34):
|
|
29
|
+
* [#33](https://github.com/mongoid/mongoid-scroll/pull/33): Remove support for Mongoid 3, 4 and Moped - [@dblock](https://github.com/dblock).
|
|
30
|
+
* [#34](https://github.com/mongoid/mongoid-scroll/pull/34): Add support for Mongoid 8 - [@dblock](https://github.com/dblock).
|
|
14
31
|
|
|
15
32
|
### 0.3.7 (2021/06/01)
|
|
16
33
|
|
|
@@ -25,7 +42,7 @@
|
|
|
25
42
|
### 0.3.5 (2016/09/27)
|
|
26
43
|
|
|
27
44
|
* [#11](https://github.com/mongoid/mongoid-scroll/pull/11): Compatibility with Mongoid 6 - [@dblock](https://github.com/dblock).
|
|
28
|
-
* [#12](https://github.com/mongoid/mongoid-scroll/pull/12):
|
|
45
|
+
* [#12](https://github.com/mongoid/mongoid-scroll/pull/12): Add Danger, PR linter - [@dblock](https://github.com/dblock).
|
|
29
46
|
|
|
30
47
|
### 0.3.4 (2015/10/22)
|
|
31
48
|
|
|
@@ -48,7 +65,7 @@
|
|
|
48
65
|
### 0.3.0 (2014/1/7)
|
|
49
66
|
|
|
50
67
|
* Compatibility with Mongoid 4.x - [@dblock](https://github.com/dblock).
|
|
51
|
-
*
|
|
68
|
+
* Implemenet Rubocop, Ruby linter - [@dblock](https://github.com/dblock).
|
|
52
69
|
|
|
53
70
|
### 0.2.1 (2013/3/21)
|
|
54
71
|
|
|
@@ -56,7 +73,7 @@
|
|
|
56
73
|
|
|
57
74
|
### 0.2.0 (2013/3/14)
|
|
58
75
|
|
|
59
|
-
*
|
|
76
|
+
* Extend `Moped::Query` with `scroll` - [@dblock](https://github.com/dblock).
|
|
60
77
|
* `Mongoid::Scroll::Cursor.from_record` can now be called with either a Mongoid field or `field_type` and `field_name` in the `options` hash - [@dblock](https://github.com/dblock).
|
|
61
78
|
|
|
62
79
|
### 0.1.0 (2013/2/14)
|
data/Dangerfile
CHANGED
data/Gemfile
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
|
-
source '
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
|
-
case version = ENV['MONGOID_VERSION'] || '
|
|
5
|
+
case version = ENV['MONGOID_VERSION'] || '9'
|
|
6
6
|
when 'HEAD' then gem 'mongoid', github: 'mongodb/mongoid'
|
|
7
|
+
when /^9/ then gem 'mongoid', '~> 9.0'
|
|
7
8
|
when /8/ then gem 'mongoid', '~> 8.0'
|
|
8
9
|
when /7/ then gem 'mongoid', '~> 7.0'
|
|
9
10
|
when /6/ then gem 'mongoid', '~> 6.0'
|
|
10
|
-
when /5/ then
|
|
11
|
-
gem 'bigdecimal', '1.3.5'
|
|
12
|
-
gem 'mongoid', '~> 5.0'
|
|
13
11
|
else gem 'mongoid', version
|
|
14
12
|
end
|
|
15
13
|
|
|
16
14
|
group :development, :test do
|
|
15
|
+
gem 'base64'
|
|
16
|
+
gem 'benchmark'
|
|
17
|
+
gem 'bigdecimal'
|
|
17
18
|
gem 'bundler'
|
|
18
|
-
gem '
|
|
19
|
+
gem 'danger', require: false
|
|
20
|
+
gem 'danger-changelog', require: false
|
|
21
|
+
gem 'danger-pr-comment', require: false
|
|
22
|
+
gem 'database_cleaner-mongoid', '~> 2.0'
|
|
19
23
|
gem 'faker'
|
|
20
|
-
gem '
|
|
24
|
+
gem 'logger'
|
|
25
|
+
gem 'mutex_m'
|
|
21
26
|
gem 'rake'
|
|
22
27
|
gem 'rspec', '~> 3.0'
|
|
23
28
|
gem 'rspec-its'
|
|
24
|
-
gem '
|
|
29
|
+
gem 'simplecov', '>= 0.22', require: false
|
|
30
|
+
gem 'rubocop', '1.66.1'
|
|
31
|
+
gem 'rubocop-rake'
|
|
32
|
+
gem 'rubocop-rspec'
|
|
25
33
|
end
|
data/README.md
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
- [The Problem](#the-problem)
|
|
5
5
|
- [Installation](#installation)
|
|
6
6
|
- [Usage](#usage)
|
|
7
|
-
- [Mongoid](#mongoid)
|
|
8
|
-
- [Mongo-Ruby-Driver (Mongoid 5)](#mongo-ruby-driver-mongoid-5)
|
|
9
7
|
- [Indexes and Performance](#indexes-and-performance)
|
|
10
8
|
- [Cursors](#cursors)
|
|
11
9
|
- [Standard Cursor](#standard-cursor)
|
|
@@ -16,21 +14,18 @@
|
|
|
16
14
|
# Mongoid::Scroll
|
|
17
15
|
|
|
18
16
|
[](https://badge.fury.io/rb/mongoid-scroll)
|
|
19
|
-
[](https://codeclimate.com/github/mongoid/mongoid-scroll)
|
|
17
|
+
[](https://github.com/mongoid/mongoid-scroll/actions/workflows/ci.yml?query=branch%3Amaster)
|
|
18
|
+
[](https://coveralls.io/github/mongoid/mongoid-scroll?branch=master)
|
|
22
19
|
|
|
23
20
|
Mongoid extension that enables infinite scrolling for `Mongoid::Criteria` and `Mongo::Collection::View`.
|
|
24
21
|
|
|
25
22
|
## Compatibility
|
|
26
23
|
|
|
27
|
-
This gem supports Mongoid
|
|
24
|
+
This gem supports Mongoid 6, 7, 8 and 9.
|
|
28
25
|
|
|
29
26
|
## Demo
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
There're also two code samples for Mongoid in [examples](examples). Run `bundle exec ruby examples/mongoid_scroll_feed.rb`.
|
|
28
|
+
Take a look at [this example](examples/feed.rb). Try with with `bundle exec ruby examples/feed.rb`.
|
|
34
29
|
|
|
35
30
|
## The Problem
|
|
36
31
|
|
|
@@ -51,16 +46,16 @@ gem 'mongoid-scroll'
|
|
|
51
46
|
|
|
52
47
|
## Usage
|
|
53
48
|
|
|
54
|
-
### Mongoid
|
|
55
|
-
|
|
56
49
|
A sample model.
|
|
57
50
|
|
|
58
51
|
```ruby
|
|
59
52
|
module Feed
|
|
60
53
|
class Item
|
|
61
54
|
include Mongoid::Document
|
|
55
|
+
|
|
62
56
|
field :title, type: String
|
|
63
57
|
field :position, type: Integer
|
|
58
|
+
|
|
64
59
|
index({ position: 1, _id: 1 })
|
|
65
60
|
end
|
|
66
61
|
end
|
|
@@ -69,48 +64,42 @@ end
|
|
|
69
64
|
Scroll by `:position` and save a cursor to the last item.
|
|
70
65
|
|
|
71
66
|
```ruby
|
|
72
|
-
|
|
73
|
-
Feed::Item.desc(:position).limit(5).scroll do |record, next_cursor|
|
|
74
|
-
# each record, one-by-one
|
|
75
|
-
saved_cursor = next_cursor
|
|
76
|
-
end
|
|
77
|
-
```
|
|
67
|
+
saved_iterator = nil
|
|
78
68
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
```ruby
|
|
82
|
-
Feed::Item.desc(:position).limit(5).scroll(saved_cursor) do |record, next_cursor|
|
|
69
|
+
Feed::Item.desc(:position).limit(5).scroll do |record, iterator|
|
|
83
70
|
# each record, one-by-one
|
|
84
|
-
|
|
71
|
+
saved_iterator = iterator
|
|
85
72
|
end
|
|
86
73
|
```
|
|
87
74
|
|
|
88
|
-
|
|
75
|
+
Resume iterating using the saved cursor and save the cursor to go backwards.
|
|
76
|
+
|
|
77
|
+
If the sort field or a saved cursor's field is no longer defined on the model, `scroll` raises `Mongoid::Scroll::Errors::NoSuchFieldError`. A defined field with a `nil` value is not considered missing.
|
|
89
78
|
|
|
90
79
|
```ruby
|
|
91
|
-
Feed::Item.desc(:position).scroll(
|
|
80
|
+
Feed::Item.desc(:position).limit(5).scroll(saved_iterator.next_cursor) do |record, iterator|
|
|
92
81
|
# each record, one-by-one
|
|
82
|
+
saved_iterator = iterator
|
|
93
83
|
end
|
|
94
84
|
```
|
|
95
85
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
Scroll a `Mongo::Collection::View` and save a cursor to the last item. You must also supply a `field_type` of the sort criteria.
|
|
86
|
+
Loop over the first records again.
|
|
99
87
|
|
|
100
88
|
```ruby
|
|
101
|
-
|
|
102
|
-
client[:feed_items].find.sort(position: -1).limit(5).scroll(nil, { field_type: DateTime }) do |record, next_cursor|
|
|
89
|
+
Feed::Item.desc(:position).limit(5).scroll(saved_iterator.previous_cursor) do |record, iterator|
|
|
103
90
|
# each record, one-by-one
|
|
104
|
-
|
|
91
|
+
saved_iterator = iterator
|
|
105
92
|
end
|
|
106
93
|
```
|
|
107
94
|
|
|
108
|
-
|
|
95
|
+
Use `saved_iterator.first_cursor` to loop over the first records or `saved_iterator.current_cursor` to loop over the same records again.
|
|
96
|
+
|
|
97
|
+
The iteration finishes when no more records are available. You can also finish iterating over the remaining records by omitting the query limit.
|
|
109
98
|
|
|
110
99
|
```ruby
|
|
111
|
-
|
|
100
|
+
Feed::Item.desc(:position).limit(5).scroll(saved_iterator.next_cursor) do |record, iterator|
|
|
112
101
|
# each record, one-by-one
|
|
113
|
-
|
|
102
|
+
saved_iterator = iterator
|
|
114
103
|
end
|
|
115
104
|
```
|
|
116
105
|
|
|
@@ -148,7 +137,7 @@ end
|
|
|
148
137
|
|
|
149
138
|
## Cursors
|
|
150
139
|
|
|
151
|
-
You can use `Mongoid::Scroll::Cursor.from_record` to generate a cursor. A cursor points at the last record of the
|
|
140
|
+
You can use `Mongoid::Scroll::Cursor.from_record` to generate a cursor. A cursor points at the last record of the iteration and unlike MongoDB cursors will not expire.
|
|
152
141
|
|
|
153
142
|
```ruby
|
|
154
143
|
record = Feed::Item.desc(:position).limit(3).last
|
|
@@ -179,15 +168,15 @@ Feed::Item.desc(:created_at).scroll(cursor) # Raises a Mongoid::Scroll::Errors::
|
|
|
179
168
|
|
|
180
169
|
### Standard Cursor
|
|
181
170
|
|
|
182
|
-
The `Mongoid::Scroll::Cursor` encodes a value and a tiebreak ID separated by `:`, and does not include other options, such as scroll direction. Take extra care not to pass a cursor into a scroll with different options.
|
|
171
|
+
The `Mongoid::Scroll::Cursor` encodes a value and a tiebreak ID separated by `:`, and does not include other options, such as scroll direction. Take extra care not to pass a cursor into a scroll with different options.
|
|
183
172
|
|
|
184
173
|
### Base64 Encoded Cursor
|
|
185
174
|
|
|
186
175
|
The `Mongoid::Scroll::Base64EncodedCursor` can be used instead of `Mongoid::Scroll::Cursor` to generate a base64-encoded string (using RFC 4648) containing all the information needed to rebuild a cursor.
|
|
187
176
|
|
|
188
177
|
```ruby
|
|
189
|
-
Feed::Item.desc(:position).limit(5).scroll(Mongoid::Scroll::Base64EncodedCursor) do |record,
|
|
190
|
-
# next_cursor is of type Mongoid::Scroll::Base64EncodedCursor
|
|
178
|
+
Feed::Item.desc(:position).limit(5).scroll(Mongoid::Scroll::Base64EncodedCursor) do |record, iterator|
|
|
179
|
+
# iterator.next_cursor is of type Mongoid::Scroll::Base64EncodedCursor
|
|
191
180
|
end
|
|
192
181
|
```
|
|
193
182
|
|
|
@@ -199,4 +188,4 @@ Fork the project. Make your feature addition or bug fix with tests. Send a pull
|
|
|
199
188
|
|
|
200
189
|
MIT License, see [LICENSE](http://github.com/mongoid/mongoid-scroll/raw/master/LICENSE.md) for details.
|
|
201
190
|
|
|
202
|
-
(c) 2013-
|
|
191
|
+
(c) 2013-2024 [Daniel Doubrovkine](http://github.com/dblock), based on code by [Frank Macreery](http://github.com/macreery), [Artsy Inc.](http://artsy.net)
|