【发布时间】:2015-09-23 09:41:30
【问题描述】:
在 Parse db 上运行 600k 行的查询。我想要的对象在那里,但它仍然没有返回任何内容。一切都工作了几个星期,然后随机停止。有任何想法吗?这是查询:
// make query on parse database to find code the person entered
let query: PFQuery = PFQuery(className: "code")
query.whereKey("code", containsString: self.codeInput.text!.uppercaseString)
query.findObjectsInBackgroundWithBlock {(objects: [AnyObject]?, error: NSError?) -> Void in
// store results
let results: NSArray = (array: objects!)
// Log the error if there is one
if (error != nil) {
self.wrongCodeAnimation()
print("error " + error!.localizedDescription)
}
// if there aren't any results, do wrong code animation
else if(results.count == 0){
print("nothing")
print(results)
self.wrongCodeAnimation()
}
// If no error, get array of results and validate the code, get the actual code for that object, and the valid state so we can pass them into the validate function
else {
let object: PFObject = results.objectAtIndex(0) as! PFObject
let code: String = object.objectForKey("code") as! String
let codeValid: Bool = object.objectForKey("valid") as! Bool
print(codeValid)
print(code)
self.validateCode(code, codeValid: codeValid, codeObject: object)
}
}
【问题讨论】:
-
我不知道 swift,但您正在将代码转换为大写。您是否检查它是否存在于数据浏览器中。您可以尝试直接在解析浏览器上运行该查询以验证
-
@virendrao 数据浏览器中确实存在,代码全部大写。我只是转换为大写,以防该人意外添加了小写字符。
-
当月达到的解析请求数是否有限制?
-
尝试删除您的 query.whereKey 并替换为“query.limit = 10”,以确保您有数据。
-
30reqs / 秒,1 个作业。免费计划
标签: xcode swift parse-platform