I have the following Firebase Structure and I use Firego to connect with Golang.
"Job":{
"-Kd0G5mRrRCXlGJmIuD0" : {
"CurrentDate" : 1487153684854,
"CustomerId" : "-Kcgz7IpH0fbs4EXaELr",
"CustomerName" : "David",
"JobName" : "Maintanence",
"JobNumber" : "101",
"NumberOfTask" : "1",
"Status" : "Active"
},
"-Kd0UwmSHRhHdPX8z2hl" : {
"CurrentDate" : 1487157576818,
"CustomerId" : "-Kcg6uppyD8yKznNXZd7",
"CustomerName" : "John",
"JobName" : "Cleaning",
"JobNumber" : "101",
"NumberOfTask" : "4",
"Status" : "Active"
}
}
My Job Struct:
type Job struct {
CustomerId string
CustomerName string
JobName string
JobNumber string
NumberOfTask string
Status string
CurrentDate int64
}
I used the folowing code to search Jobname = "Maintanence"
err = dB.Child("Job").OrderBy("JobName").EqualTo("Maintanence").Value(&job)
if err!=nil{
log.Println("Error:",err)
}
if len(job)==0{
log.Println("map null:",job)
}else{
log.Println("map not null:",job)
}
and it print:
map not null: -Kd0G5mRrRCXlGJmIuD0" : {
"CurrentDate" : 1487153684854,
"CustomerId" : "-Kcgz7IpH0fbs4EXaELr",
"CustomerName" : "David",
"JobName" : "Maintanence",
"JobNumber" : "101",
"NumberOfTask" : "1",
"Status" : "Active"
}
But when I trird to search for the Jobnumber = "101" using following code
err = dB.Child("Job").OrderBy("JobNumber").EqualTo("101").Value(&job)
if err!=nil{
log.Println("Error:",err)
}
if len(job)==0{
log.Println("map null:",job)
}else{
log.Println("map not null:",job)
}
it print:
map null:{}
Why I can't search and print the JobNumber = "101" , when I was able to search and print JobName = "Maintanence" ?