Is it possible to access documents in a database in CouchDB from another database's design documents?
-
It seems like you're only able to MapReduce the database your design doc is in. I'm looking to access the _users database from within a CouchApp, if that helps.
-
Answer:
if you are asking about view generation... views are only built in the database that contains the design doc.
J Chris Anderson at Quora Visit the source
Other answers
No, not directly, since only system administrators can access the _users database. However, you could still continously replicate the _users database to a mirror database and treat it like any other database. You can combine several databases with many couchapps into one application via the rewrite list in a design document you use as couchapp. In your Configuration section httpd parameter secure_rewrites should be set to false to allow you to use ../../../ to create a path to another database than the one holding the design document with the rewrite list. Your rewrites in your design document (couchapp) needs to include a rule that point to the database you want to access with a rule e.g. like this: "rewrites": [ { "from": "users/:email", "to": "../../../users_mirror/_design/users/_view/by_email" "query": { "key": ":email", "include_docs": "false" } }, ... In this example you would need do have a design document in the _users database (or just in users_mirror) that holds a view that I called by_email. This view could then limit the output from the user database as long as other paths to the database are blocked. You might even want to create a function in a list to add even more security, verifying the role of the user and adding logic. The rewrite would then be something like this { "from": "users/:email", "to": "../../../users_mirror/_design/users/_list/userfilter/by_email" "query": { "key": ":email", "include_docs": "true" } } Adding filtering to the replication could add further security to this. Remember: the design document (couchapp) with the view need to be in the same database as the data.
Johs Ensby
You can use the _rewriter for that by disabling secure_rewrite option in settings and use such rule: { "from": "/users/*", "to": "../../../_users/*" }
Benoit Chesneau
Related Q & A:
- How to get another user's details using RestFB?Best solution by Stack Overflow
- Is it possible to access the Mac address book API from pure Java?Best solution by Stack Overflow
- Is it possible to forward mail from one Yahoo email account to another?Best solution by Yahoo! Answers
- Can you have a phone from one company and have another company's plan?Best solution by ChaCha
- Is it possible to transfer your iTunes playlist from one computer to another?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.