-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is db.rel.find() have an option for paging? #106
Comments
Perhaps use https://github.com/pouchdb-community/relational-pouch#dbrelfindtype-options |
I have used auto generated id(UUID). So how can I use start key? |
In Ember Pouch we use startkey 'post_2_' and endkey 'post_3_' because we know our ID's always start with post_2_ for the |
Consider like this, I have 10 records with following id structure post_2_randomUUID. If I want to fetch the records by 2 batch, for each batch I need 5 records. How can I implement this? |
Start with startkey |
In this way I don't know the next start key because post_2 is randomUDID. Then how can I call next batch? |
? I don't seem to understand you. You know the next start key because it is the same as the ID in the last record. |
Ok. This is my sample code
It will store in following format in pouchdb
If I try to fetch like below format not working. Give empty response.
If I change like this it will working. Give two docs in response.
So how I pass start key? I don't know the id first time. Only I know post. |
Use 'post_2_' the first time. As I said "The startkey does not have to exist" it just has to come before the first posible key. |
thank you. I tried this also but it returns empty response only.
|
Sorry I am working to much with pouchdb-find I forgot you had to just write See: var PouchDB = require('pouchdb');
PouchDB.plugin(require('relational-pouch'));
var db = new PouchDB('https://martinic.couchcluster.com/bloggr');
db.setSchema([
{
singular: 'post',
plural: 'posts',
relations: {
author: {belongsTo: 'author'}
}
},
{
singular: 'author',
plural: 'authors',
relations: {
posts: {hasMany: 'post'}
}
}
]);
db.rel.find('post',{startkey: null, limit: 6}).then(res => {
console.log(res)
}).catch(err => {
console.log ('error', err);
}); |
Thanks it's working now. How to pass selector and sorting in this way? |
Hi Guys,
I am using relational pouch for data fetching. How can i implement the data fetch by paging using db.rel.find()
The text was updated successfully, but these errors were encountered: