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();; }
const fetchNextPaintings = lastVisible => async dispatch => { try { dispatch({ type: PAINTINGS_FETCH, }); const firebase = require('firebase'); // eslint-disable-line global-require require('firebase/firestore'); // eslint-disable-line global-require const db = firebase.firestore(); const snapshots = await db .collection('paintings') .orderBy('createdAt', 'desc') .startAfter(lastVisible) .limit(FETCH_LIMIT) .get(); dispatch({ type: PAINTINGS_FETCH_NEXT, payload: parseSnapshots(snapshots), lastVisible: snapshots.docs[snapshots.docs.length - 1], }); } catch (err) { console.log('err:', err); dispatch({ type: PAINTINGS_FETCH_ERROR, payload: err, }); } }
.collection('paintings') .orderBy('createdAt', 'desc') .limit(FETCH_LIMIT); const snapshots = await query.get(); dispatch({