I have 2 questions relating to this query:
I'm running a query in Firebase, the query returns the result I'm looking for but when I try to access the data in the query, it is nil
How can I access the tag key in the query? It is 1 deep
Thank you in advance
Query
ref.child("users")
.queryOrderedByChild("receivePostRequest/status")
.queryEqualToValue(true)
.observeEventType(.Value, withBlock: {snapshot in
JSON result
Optional({
lgmSZ1HnMnSzE71kCLfdxK8AN2G2 = {
age = 18;
email = "lon1@gmail.com";
firstname = Jamie;
lastname = lon;
latitude = "37.3325232";
longitude = "-122.0286527";
profilePic = "users/profilePhoto/W6pK2HHA1TZC9wicnCaODQhHvoi1.jpg";
receivePostRequest = {
status = 1;
tag = tagSample;
};
userId = lgmSZ1HnMnSzE71kCLfdxK8AN2G2;
};
})
This is the complete query
ref.child("users")
.queryOrderedByChild("receivePostRequest/status")
.queryEqualToValue(true)
.observeEventType(.Value, withBlock: {snapshot in
print(snapshot.value["firstname"])
})
JSON
{
"posts" : {
"-KJGom2RvmWkfbvsFXij" : {
"postAddress" : "Post Address",
"postCompletionAddress" : "post completion address",
"postCreationTime" : "postCreation Time",
"postDateTime" : "Date and Time",
"postDescription" : "Post Detail",
"postPay" : "post Pay",
"postTitle" : "Post Title",
"status" : "pending",
"userAiD" : "W6pK2HHA1TZC9wicnCaODQhHvoi1",
"userBiD" : "lgmSZ1HnMnSzE71kCLfdxK8AN2G2"
},
},
"users" : {
"W6pK2HHA1TZC9wicnCaODQhHvoi1" : {
"age" : 18,
"email" : "ama@gmail.com",
"firstname" : "jam",
"lastname" : "lime",
"latitude" : 37.332172,
"longitude" : -122.035089,
"profilePic" : "users/profilePhoto/W6pK2HHA1TZC9wicnCaODQhHvoi1.jpg",
"receivePostRequest" : {
"lat" : 28.10277584477151,
"latitude" : 37.33067237,
"long" : -81.4587166999294,
"longitud" : -122.03014382,
"status" : false,
"tags" : {
"tag1" : 444
}
},
"userId" : "W6pK2HHA1TZC9wicnCaODQhHvoi1"
},
"lgmSZ1HnMnSzE71kCLfdxK8AN2G2" : {
"age" : 18,
"email" : "weirhe@gmail.com",
"firstname" : "james",
"lastname" : "leen",
"latitude" : 37.3325232,
"longitude" : -122.0286527,
"profilePic" : "users/profilePhoto/W6pK2HHA1TZC9wicnCaODQhHvoi1.jpg",
"receivePostRequest" : {
"status" : true,
"tag" : "tag 1"
},
"userId" : "lgmSZ1HnMnSzE71kCLfdxK8AN2G2"
}
}
}