I am Writing a code to bring data of water from yesterday. but when I write LimitToLast its working perfectly but the data i am getting is not right so I write LimitToFirst instead of LimitToLast but after writing LimitToFirst my code start giving error in console.
cloudDb.collection(...).where(...).where(...).orderBy(...).limitToFirst is not a function
I have write the code like this
var water1 = 0;
cloudDb.collection('AKVO_RND').where("machine_id", "==", localStorage.getItem('machineid')).where("date", "<=", date_yesterday).orderBy("date").limitToFirst(1).get().then(function (querySnapshot) {
querySnapshot.forEach(function (doc) {
water1 = doc.data().water;
});
})
If you check the reference documentation for the Query class you'll find that there is no limitToFirst method - it only has limit and limitToLast. You'll want to use limit(1) in your code.