@nxtedition/lib 19.0.20 → 19.0.22
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.
- package/deepstream.js +12 -9
- package/package.json +1 -1
package/deepstream.js
CHANGED
|
@@ -119,28 +119,31 @@ function get(ds, name, ...args) {
|
|
|
119
119
|
)
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
function query(ds, designId, options) {
|
|
122
|
+
function query(ds, designId, options, state = options.state ?? ds.record.PROVIDER) {
|
|
123
123
|
const next = (startkey, prevRows, limit) =>
|
|
124
124
|
!limit
|
|
125
125
|
? rxjs.of({ rows: prevRows ?? [] })
|
|
126
126
|
: ds.nxt.record
|
|
127
127
|
.observe(
|
|
128
|
-
designId
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
`${designId}:query?${qs.stringify(
|
|
129
|
+
{
|
|
130
|
+
...options,
|
|
131
|
+
startkey,
|
|
132
|
+
limit: Number.isFinite(limit) ? limit : null,
|
|
133
|
+
},
|
|
134
|
+
{ skipNulls: true },
|
|
135
|
+
)}`,
|
|
136
|
+
state,
|
|
135
137
|
)
|
|
136
138
|
.pipe(
|
|
137
139
|
rxjs.switchMap(({ rows, finished }) => {
|
|
138
140
|
const nextRows = prevRows ? [...prevRows, ...rows] : rows
|
|
139
|
-
if (
|
|
141
|
+
if (finished) {
|
|
140
142
|
return rxjs.of({ rows: nextRows })
|
|
141
143
|
} else {
|
|
142
144
|
const last = rows.pop()
|
|
143
145
|
assert(last.key)
|
|
146
|
+
assert(rows.length > 0)
|
|
144
147
|
return next(last.key, nextRows, limit - rows.length)
|
|
145
148
|
}
|
|
146
149
|
}),
|