0

I've two tables A and B in pouchDB. One column in table A references table B. Assume table A has a1, a2, b1 columns and table B has b1, b2 and b3 columns. I'm retrieving a list of items from A. Here instead of column b1 in table A, I want table B's b2 column. How can I do this in pouchDB.

const localDB = new PouchDB('A');
const remoteDB = new PouchDB('http://user:[email protected]:5984/A');
localDB.find({selector: { "a1": { $eq: "search_value" }}, function (err, results) {
    return results;
});
3
  • So you want to update your documents form A and replace b1 by b2? If so, you should do some sort of "migration". You can basically have a job that queries all documents of A. Then foreach of them, it queries the B document and updates the A document. PouchDB-migrate could be useful in this case. Dec 15, 2017 at 18:31
  • @AlexisCôté, I don't want to affect the database. I just want this change locally. And I also don't want to do foreach. Can this be done? Dec 15, 2017 at 19:37
  • You can use a view to emit the document linked (see this wiki). For example, you could query for the document A and you would receive as a response two document : one being the document A, the other being the document B. Then, you could modify your document A locally. Dec 15, 2017 at 20:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.