Reputation: 66410
This is the structure of my data:
ft-public-records
2015-01-01 00:00:00 GMT
addedByUser: "[email protected]"
rating: 1
time: "2015-01-01 00:00:00 GMT"
timestamp: 1490437551.593684
Without queryStartAt
, I can get the object without problems:
self.publicRef.child("2015-01-01 00:00:00 GMT").queryOrdered(byChild: "rating").observe(FIRDataEventType.value, with: { snapshot in
print(snapshot)
})
Result:
Snap (2015-01-01 00:00:00 GMT) {
addedByUser = "[email protected]";
rating = 1;
time = "2015-01-01 00:00:00 GMT";
timestamp = "1490437551.593684";
}
But the moment I add the queryStarting
at 1 for ratings, I get null.
self.publicRef.child("2015-01-01 00:00:00 GMT").queryOrdered(byChild: "rating").queryStarting(atValue: 1).observe(FIRDataEventType.value, with: { snapshot in
print(snapshot)
})
Result:
Snap (2015-01-01 00:00:00 GMT) <null>
What am I missing please?
Upvotes: 1
Views: 564
Reputation: 66410
I ended up restructuring the json by adding another child houmie-2013-01-01 00:00:00 UTC
to the 2013-01-01 00:00:00 UTC
{
"ft-public-records" : {
"2013-01-01 00:00:00 UTC" : {
"houmie-2013-01-01 00:00:00 UTC" : {
"rating" : 1,
"time" : "2013-01-01 00:00:00 UTC",
"timestamp" : 1.490550817827253E9,
"username" : "houmie"
}
}
},
}
This works for me now:
self.ref.child("ft-public-records").child("2013-01-01 00:00:00 GMT").queryOrdered(byChild: "rating").queryStarting(atValue: 1).observe(FIRDataEventType.value, with: { snapshot in
print(snapshot)
})
Upvotes: 1