我正在执行复合查询,尽管删除组合时我得到了全部数据,但是放入
时却从数据库中什么也没有.where().where()
这是我用来执行此操作的方法:
async function myMethod (userDoc, apartmentDoc, json) {
try {
// this variables will be used in getting tickets' snapshot
var tickets = [];
// this converts date from json to unix time
var unixTimestamp = Math.round(new Date(json.TimePreferred).getTime() / 1000);
// we will get the whole day query by
// trpping timestamp from the first second until the last second of the day
//this is start query
var start = unixTimestamp;
console.log('This is start query', start);
// this is end query
var end = unixTimestamp + 86400;
console.log('This is end query', end);
var ticketsSnapshot = await usersRoot.doc(userDoc.id).collection('Apartments').doc(apartmentDoc.id).collection('Tickets').where('TimePreferred', '>=', start).where('TimePreferred', '<=', end).get();
console.log('This is the length of data we got',ticketsSnapshot.docs.length);
// i can use forEach here because this is first level firebase (just one doc id is unknown)
for (const ticketDoc of ticketsSnapshot.docs) {
// Rewrite the timestamp objects
var object = rewriteTheTimestamp(ticketDoc);
// console.log('this is our time from database ',ticketDoc.data().TimePreferred._seconds);
tickets.push(object);
}
return tickets;
} catch (error) {
console.log('err at Getting ticketsSnapshot 3', error);
}
}
我希望从数据库获得的文档是(如所引用的):
我得到的结果是:
This is start query 1554076800
This is end query 1554163200
This is the length of data we got 0