-
Notifications
You must be signed in to change notification settings - Fork 17
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
Support pageable query and return the pageable results with total count.... #39
Comments
can you provide an example of the type of query you're trying to execute? some equivalent curl or dump of a manual request/response would help. |
I have a such typed couch DB The result is the struct: the field "total_rows" is just the affect rows instead of total rows that match the query condition how can I get the total rows for this typed query? |
sorry but I'm still not sure I understand. Are you able to run the query using CouchDB's Fauxton or curl directly and you get the total rows? If so, can you provide such a query? I see you're using FindQuery's limit and skip; isn't the issue that you're skipping and limiting but at the same time you're trying to get the total rows that match the query condition? All in all, I'm not sure if the question is more a CouchDB usage question or something related to couch-rs. |
Actually, my question is related to couch-rs usage. Which function in couch-rs can return the pageable results with the total records (total records means that the count of match the conditions instead of current page's total) ? |
If you were using views, I think you'd want to check about https://docs.couchdb.org/en/stable/ddocs/views/intro.html if you run the query without ...but you're using _find which does not support reduce operations yet: I think you then want to check the |
If I use couch-rs to invoke the views, which function can meet my requirement? |
looking at your query selector: { "identifiers": { "$elemMatch": { "identifierType": { "$eq": r#type }, "identifierValue": { "$eq": value } } although you could use views, I don't think you want to as your query is dynamic. You will not want to have a view for every possible query selector value. {
"selector": {
"identifiers": {
"$elemMatch": {
"identifierType": {
"$eq": "EMAIL_ADDRESS"
},
"identifierValue": {
"$eq": "wei41@xxxxx.com"
}
}
}
},
"limit": 40
} The response will contain a {
"docs": [
...
],
"bookmark": "g1AAAABweJzLYWBgYMpgSmHgKy5JLCrJTq2MT8lPzkzJBYorGBhZGicZpRkkJ1qam5qbpFiYGZuZm6YZJaYYGJqnmJiC9HHA9BGlIwsAdSsdXw",
} Then you want to use a loop so that the request is repeated, using the last received Basically you're executing requests for all the pages until you get to the end and you know the total number of entries. If you only care about counting, and you don't want to look at the row data, you can also use the If you want to count and also get the row data, then you do want to get all fields. |
For the pageable query, is there any way to return the affect rows for specific offset and limit count, and with the total rows for the specific query condition...
The text was updated successfully, but these errors were encountered: