Comments (9)
You can use db.list() with an array of ids:
db.list {keys: doc_keys, include_docs: true}, (error, data) ->
from nano.
See my commit @ https://github.com/InTheFiveByFive/nano/commit/a96a50d2e1fd52ca69ca70bea6163e4445bd7c88
from nano.
You're using POST which is supposed to send data to the database, not GET something. Also, as mentioned, the function already exists, you just need to add {include_docs: true} as parameter:
function list_docs(params,callback) {
if(typeof params === "function") {
callback = params;
params = {};
}
return relax({db: db_name, path: "_all_docs", method: "GET", params: params},callback);
}
from nano.
Per the bulk document api (http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API),
By POSTing to _all_docs you can get a set of documents with arbitrary keys
Simple example to fetch the keys bar and baz and include the complete document in the result set:
curl -d '{"keys":["bar","baz"]}' -X POST http://127.0.0.1:5984/foo/_all_docs?include_docs=true
db.list() will return all documents, not a subset. To retrieve a subset of documents you POST with the body set to the list of keys.
from nano.
I'm currently away at a conference with limited time so can't follow up right now. If you can prepare a pull request I can check it out. If not just give me 1/2 days to review this and put in in npm
. if this is a bug, i havent looked at it yet :)
from nano.
Ok, I couldn't stop myself from reading this
@InTheFiveByFive please submit a pull request doing:
Minimal: function bulk_docs(docs,callback) -> function bulk_docs(docs, params, callback)
just if typeof params === function
and preserve existing api behavior. so this should break any existing production nano code. am i missing something here?
if this is the case ill accept a pull request and publish to npm.
thanks for submiting this issue and working on this. we are always super excited to have more people invested in our little community. feel free to add your projects and community to our wiki :)
from nano.
Hmm, "keys" is not the same as "startkey" and "endkey", it does indeed return a subset with only the documents requested by key, so it's the same behavior as POSTing the keys in the body. However, I can't find that in the API, so I suppose it's better to use POST.
from nano.
@InTheFiveByFive any updates on this or did this ended up not being necessary?
from nano.
FYI, after testing the changes in my application, this issue is not fixed. It turns out the the bulk read api uses POST _all_docs path whereas the bulk write api uses the POST _bulk_docs path.
So for multiple downloads by key, list_docs() has the right path but the wrong verb and bulk_docs() has the right verb and the wrong path.
I'd propose we go with the original design of adding a new method to expose POST _all_docs. No need to revert pull request #54, as it just added params support which might be useful in other scenarios.
from nano.
Related Issues (20)
- Does nano support purge? HOT 2
- db.attachment.get file- 'could not be opened because it is empty'
- Can not get correct userctx HOT 2
- Couch DB 2 compatibilty HOT 3
- bulk() with _deleted:true causes error HOT 3
- db.multipart.get does not work with Cloudant Local 1.0.0.5 HOT 1
- Enable permanent replication by writing to "_replicator" database instead of "_replicate" database. HOT 3
- Support temp view
- Doubt on db access of live app HOT 2
- What is the keys in view function based on? Is it the key you emit in the views/map function? HOT 1
- How do you update _rev to update a document?
- uploaded files displaying base64 data in the browser (attachments not viewable)
- Problem with OR -clauses? HOT 1
- Error: badarg every few hours
- Error: {error,emfile} HOT 1
- Example Lazy Creation of View
- Query string encoded when using array of keys
- Database permissions
- db.fetch array of id error
- Attempting to return simple list of documents, small issue
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 nano.