I have tried to convert timestamp into date object and string also but no success.
Note: The date field in firestore is of type Timestamp.
I'm querying documents with a date greater than '2018-08-03' in the collection. Below is a picture of the collection of transactions (left) and the document(right) which should be part of the array of documents returned, because the date is greater than '2018-08-03'.
This is the code:
const firstDay = new Date('2018-08-03');
const timestamp1 = admin.firestore.Timestamp.fromDate(firstDay);
const trans = [];
const docRef = db.collection('Users').doc(uid).collection('transactions').where('item_id', '==', item_id)
.where('date', '>', timestamp1);
await docRef.get()
.then((snapshot) => {
snapshot.forEach((doc) => {
trans.push({ transaction_id: doc.id, transaction: doc.data() });
});
})
.catch(err => new Error('cannot get the documents', err));
Expected result: should be an array with transactions with a date greater than specified above.
Actual result: empty array.
Assumptions: Since its working for equality ==, I assumed that > and < would work. Anything I'm missing here?
Logs: Below you can see logs after trying "==" (equal to timestamp1)
firstDay: Fri Aug 03 2018 02:00:00 GMT+0200 (Central European Summer Time)
timestamp1: Timestamp { _seconds: 1533254400, _nanoseconds: 0 }
```[
{
"transaction_id": "1qKbdNn1bWHr4lAog3D6Umq3xd4oMWt5zb6vR",
"transaction": {
"iso_currency_code": "USD",
"amount": 500,
"date": {
"_seconds": 1533254400,
"_nanoseconds": 0
},
"categories": [
"Food and Drink",
"Restaurants"
],
"account_id": "Xeqyv7k5yrtj9V17Q6B8uP54WgZ6RgCdRB8jn",
"category_id": "13005000",
"payment_meta": {
"payment_method": null,
"payment_processor": null,
"reason": null,
"payer": null,
"by_order_of": null,
"reference_number": null,
"payee": null,
"ppd_id": null
},
"pending": false,
"name": "KFC",
"transaction_type": "place",
"category": "Food and Drink",
"location": {
"lon": null,
"lat": null,
"address": null,
"region": null,
"city": null,
"postal_code": null,
"country": null,
"store_number": null
},
"item_id": "zGRkpP3QkzI89zKyDjZ7FPDrXd5G3Bco5ENlR",
"recurrent": 0,
"institutionId": "ins_3",
"account_owner": null,
"transaction_id": "1qKbdNn1bWHr4lAog3D6Umq3xd4oMWt5zb6vR"
}
}
]
--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/1ce0f9cf-c283-4654-9110-777a0b070ddd%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/813da103-e43f-458a-83db-b2610e6a0e88%40googlegroups.com.