const getComments = async (parentId, slug, type, limit) => { const db = firebase.firestore(); let commentsQuery = db.collection('comments3') .where('postType', '==', type) .where('postId', '==', slug) .where('parentId', '==', parentId || null) .orderBy("createdAt"); if (limit) { commentsQuery = commentsQuery.limit(limit); } return commentsQuery.get();; }
deleteFavorite(id: string): Promise<void> { const db = firebase.firestore(); if (this.userId) { return db.collection('favorites').where('user', '==', this.userId).where('dish', '==', id).get() .then(doc => { doc.forEach( docu => { return db.doc('favorites/' + docu.id).delete(); }); }); } else { return Promise.reject(new Error('No User Logged In!')); } }
/* postFavorites(dishids: any) { return this.http.post(baseURL + 'favorites/', dishids) .catch(error => { return this.processHTTPMsgService.handleError(error); }); } */ isFavorite(id: string): Promise<boolean> { const db = firebase.firestore(); if (this.userId) { return db.collection('favorites').where('user', '==', this.userId).where('dish', '==', id).get() .then(doc => { return !doc.empty; }); } else { return Promise.resolve(false); } }