Comments (8)
Nice catch! :D May I ask you to submit a pull request?
from levelgraph.
Continuing on the discussion here: 86847a4#commitcomment-6691590
What if we implement a getStream which accepts as an option to start from a certain triple? That's a good way to paginate, yet you will not give a page=X, but now you will give a starttriple=SPO instead.
from levelgraph.
Yes, that was what I was thinking. It's a good way to go. Would you like to
be a contributor here? So we might work on this together.
from levelgraph.
Continuing in a new issue as this is getting off topic: #81
from levelgraph.
bump... was this ever fixed?
from levelgraph.
Definitely not, the whole 'limit + offset' thing is kind of broken if you read the whole discussion.
The right approach will be to start reading back from where it left, e.g. giving a startTriple
parameter.
Anyway, @neonstalwart would you like to submit a PR on this issue? Maybe with @pietercolpaert fix + unit tests?
from levelgraph.
Yes, pagination using the last key info is right way. I've added the 'last'
event
and next
option to solve the stream pagination problem in level-subkey. Just reference:
var callbackStream = require('callback-stream')
var lastKey = null;
function nextPage(db, aLastKey, aPageSize, cb) {
var stream = db.readStream({next: aLastKey, limit: aPageSize})
stream.on('last', function(aLastKey){
lastKey = aLastKey;
});
stream.pipe(callbackStream(function(err, data){
cb(data, lastKey)
}))
}
var pageNo = 1;
dataCallback = function(data, lastKey) {
console.log("page:", pageNo);
console.log(data);
++pageNo;
if (lastKey) {
nextPage(db, lastKey, 10, dataCallback);
}
else
console.log("no more data");
}
nextPage(db, lastKey, 10, dataCallback);
from levelgraph.
👍 to removing offset
entirely in favor of adding start
or startTriple
syntax.
Pretty limit
ed pagination options atm...heh...
from levelgraph.
Related Issues (20)
- Why save all permutations? HOT 5
- Tree Traversal & Querying HOT 3
- Assistance with query on a DAG HOT 1
- joins do not work if the values are different than the objects themselves HOT 1
- use on mobile? P2P? encryption? realtime?
- unreachable code after return statement :4758
- this.db.approximateSize is not a function HOT 2
- error with example stream search code HOT 2
- Uncaught TypeError: this.once is not a function
- Triple identifiers HOT 1
- Additional Documentation Needed
- Uncaught TypeError: this.db.approximateSize is not a function
- performance expectations for levelgraph
- Error using level-sublevel@6 HOT 2
- Levelgraph searches fail to resolve; wait indefinitely after finding solution(s)
- Version bump HOT 10
- getStream doesn't emit end event
- Sync local <> external database HOT 5
- does not work with persistent level db HOT 1
- offset behaviour changes depending on type of filter HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from levelgraph.