I am using PouchDB on an Ionic 2 app that syncs with my CouchDB that is on AWS.
I have created a design document in futon and this works well if I go to http://my-ip-address:5984/wardround_jobs/_design/teams/_view/teams - I can see the JSON that is output by the map/reduce used in my design.
I am now trying to figure out how to access this in my app.
I start with this - it gives me all documents:
return new Promise(resolve => {
this.db.allDocs({
include_docs: true
}).then((result) => {
console.log(result);
}).catch((error) => {
console.log(error);
});
});
I can then amend this to get back one specific document:
return new Promise(resolve => {
this.db.get('0448071807c0f37f53e06aab54034a42').then((result) => {
console.log(result);
}).catch((error) => {
console.log(error);
});
});
But if I try and get back my design view using this code then I get back an error:
return new Promise(resolve => {
this.db.get('_design/teams/_view/teams').then((result) => {
console.log(result);
}).catch((error) => {
console.log(error);
});
});
The error is:
CustomPouchError {
status: 404,
name: "not_found",
message: "missing",
error: true,
reason: "missing"
}
How can I access the result from my map/reduce within my app?
EDIT - with the help of Alexis I got this working ...
return new Promise(resolve => {
this.db.get('teams/teams').then((result) => {
console.log(result);
}).catch((error) => {
console.log(error);
});
});