Hi there,
Ive have a ‘Campaign’ table of objects with a column called ‘referralCode’. This referralCode is a uniquely generated string, such as - ‘7541a545-6780-49bb-a18a-82452ca7f7fd’
In my iOS app, I am trying to search for and find the Campaign object, matching this referralCode value.
My code is like…
let query = BackendlessDataQuery()
let whereClause = "referralCode = '7541a545-6780-49bb-a18a-82452ca7f7fd'"
query.whereClause = whereClause
backendless.data.of(Campaign.ofClass()).find(
{ (result: AnyObject!) -> Void in
print(result.currentPage().count)
},
error: { (fault: Fault!) -> Void in
print("Server reported an error: \(fault)")
})
I know for a fact that there is only 1 object in my table that matches that query, but the ‘currentPage()’ results returns all objects (the count is 10)
Unsure why that could be… any ideas?
Thanks!
P.S. AppID = ‘29100CD0-A42D-0188-FFEC-947AB5CA5900’ , if that helps anything
Hi Simon,
Please, try:
let whereClause = "referralCode = \'7541a545-6780-49bb-a18a-82452ca7f7fd\'"
no luck… still getting all the objects back from the table
Please send also secretKey of your app to support@backendless.com - we investigate it and find a solution asap
Thanks, which secret key are you wanting specifically? for iOS?
Ok, you created ‘query’, but didn’t use it.
Please, change your line 594:
backendless.data.of(Campaign.ofClass()).find(query,
response: …
Here is my sample:
func findCampaignByReferralCode() {
let dataQuery = BackendlessDataQuery()
dataQuery.whereClause = "referralCode = \'7541a545-6780-49bb-a18a-82452ca7f7fd\'"
var error: Fault?
let bc = backendless.data.of(Campaign.ofClass()).find(dataQuery, fault: &error)
if error == nil {
let campaign = bc.data[0] as! Campaign
print("Campaign have been found: \(bc.data) -> <\(campaign.referralCode)>")
}
else {
print("Server reported an error: \(error)")
}
}
and a log:
http://support.backendless.com/public/attachments/0f653bfdebdefca655bbe51002c19f3b.png</img>
Oh my… Cant believe I got tripped on such a rookie mistake!!!
Thanks for helping pointing that out. Was indeed missing the ‘query’ in the find call.
Thanks!!