couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Cottlehuber <>
Subject Re: Re: Cross/Joined Database Access?
Date Wed, 23 Mar 2011 21:44:31 GMT
On 23 March 2011 20:47, Marc Schwering <> wrote:
> So there is no way to span queries along multiple connections right? I thought there
might be a solution using the replication / sharding features of couch?
> Am 22.03.2011 um 12:26 schrieb
>> you would have to do multiple http requests, i think.
>> would it be possible to combine all of the dbs into one database and just
>> have a field = user1,user2 etc?

This is very common - see and the nice
picture below it for an example.

>> somethings like this seem weird, coming from relational databases, but thats
>> couchdb.
>> On Tue, Mar 22, 2011 at 9:02 PM, Marc Schwering <>wrote:
>>> Hi there.
>>> Is it possible // How do i Search on multiple Databases?
>>> Given one Layout/Schema of Entities:
>>> Postings => id; title; content; timestamp
>>> This Schema exists due multiple instances of one Application (for different
>>> Users) on n Databases. Like: db1,db2,db3
>>> I want to do two fetches:
>>> a) all Posts since time X until Y sorted by timestamp. from db1 & db3.
>>> b) all Posts since time X until Y sorted by timestamp. from db2 & db3.
>>> Is that possible? If so, how?
>>> Thanks in advance
>>> Marc
>>> --
>>> M.Schwering

Long story short if this is a critical requirement for your app, it
may make more sense to keep all data in a single DB, and use
validation functions, replication filters, and either duck typing or
tagging to ensure you know who "owns" or can access each doc.

If you *need* to keep data private, another workaround is to use
multiple couches:

one db per user, private - they would replicate / talk to only this personal DB.
have one-way replication from each per-user db to a larger DB which
consolidates all user data, excluding any private stuff where
run your spanning queries from this DB.
optionally use client-side code to pull in any private data from the
person's private DB.

for time-bound queries, try something like emitting an array of JSON {
"year": "2001", "month" and ensure you use
more info on your app might help give a better answer.


View raw message