[Firebase]クエリでstartAt使用例

クエリでstartAt使用例

            const today = new Date();
            const yyyy = today.getFullYear();
            let mm = today.getMonth() + 1;
            let dd = today.getDate();
            const yyyymmdd = yyyy + "," + mm + "," + dd;
            var startDate = new Date(yyyymmdd);
            
            firebase.firestore()
            .collectionGroup("samplecollection") 
            .orderBy("createdAt", "asc").startAt(startDate)
            .limit(10)
            .get()
            .then(querySnapshot => {
                querySnapshot.forEach(doc => {
                    console.log('success');
                }, (error) => {
                    console.log('error');
                });
            })

投稿者: kinkun

保有資格 Salesforce Certified Platform App Builder T Salesforce Certified Platform Developer I Salesforce Certified Platform Developer II Salesforce Certified Administrator

コメントを残す

メールアドレスが公開されることはありません。