You’re storing Firestore timestamp’s in the database.
There are two problems with the code you shared:
tommorowvariable is a number (the number of milliseconds since the epoch). Since you store date/time in Firestore, you’re trying to compare a number with a date/time, which will never match.
Since you’re storing a date/time, getting the documents for a day is a range operation. You want all documents between date/time A and date/time B.
If you want all documents with a date/time between now and 24 hours from now, that’d be:
const nowTimestamp = Date.now(); const now = new Date(nowTimestamp); const tommorow = new Date(nowTimestamp + 24*60*60*1000); firebase.firestore .collection("consultations") .where("date", '>=', now) .where("date", '<', tomorrow)
Another problem in your code that you’re trying to call
set on a query, which is not possible. You’ll need to:
- Execute the query to get the documents that match it.
- Loop over the documents in your code.
- Update each document in turn.
For more on this, I recommend checking out: How to use where and update
CLICK HERE to find out more related problems solutions.