Within my Ionic2 application, I have created a provider to inject PouchDB design documents.
However, I encountered this TypeScript error:
Typescript Error
Cannot find name 'emit'.
src/providers/design-docs.ts
if (user.location) {
emit(user._id, user.email, user.location);
I am uncertain if it is the best practice to store design docs in a provider, so I am seeking advice on what steps to take next.
Below is the code for the provider:
import { Injectable } from '@angular/core';
@Injectable()
export class DesignDocs {
DESIGN_DOCS =
{
views:
{
filters: {
byDocIds: function (doc, req) {
if (!req.query.docIds)
return false;
var docIds = JSON.parse(req.query.docIds);
if (!docIds || !Array.isArray(docIds))
return false;
return docIds.indexOf(doc._id) > -1;
}
},
views: {
haslocation: {
map: function (user) {
if (user.location) {
emit(user._id, user.email, user.location);
}
}
},
email: {
map: function (doc) {
emit(doc.email, doc);
}
},
...
}
}
};
constructor(
) {
}
}