I'm relatively new with firestore and wasn't able to find a solution to my problem online so I thought I might post it.
I'm looking to query documents in an existing collection. The documents all have a timestamp field.
When I attempt to query for all documents ">" or "<" right now, the query works fine. When I attempt to query for ">" or "<" 7 days ago, the query returns nothing. I'm sure that I'm probably just missing something small. Thanks for any help!
These return documents as expected:
db.collection("****").where('display', '==', true).where('createdAt', '>', today).get().then(function(querySnapshot) {
and
db.collection("****").where('display', '==', true).where('createdAt', '<', today).get().then(function(querySnapshot) {
These don't return anything:
var today = new Date()-604800000;
db.collection("****").where('display', '==', true).where('createdAt', '>', today).get().then(function(querySnapshot) {
and
db.collection("****").where('display', '==', true).where('createdAt', '>', today-604800000).get().then(function(querySnapshot) {
and just for the heck of it
var today = new Date()-1;
db.collection("****").where('display', '==', true).where('createdAt', '>', today).get().then(function(querySnapshot) {
If someone could point out what I'm doing wrong, I would greatly appreciate it. Thanks!