参考
http://strongloop.com/strongblog/defining-and-mapping-data-relations-with-loopback-connected-models/
如果我定义了客户和订单之间的关系,以便订单属于客户,我如何使用 iOS SDK 从订单中获取客户详细信息?我目前正在使用 invokeStaticMethod 来获取过滤列表,如下所示:
func getOrders() {
var prototype: LBModelRepository = adapter.repositoryWithModelName("orders")
adapter.contract.addItem(SLRESTContractItem(pattern: "/orders", verb: "GET"), forMethod: "orders.filter")
var params = [
"filter[where][customerId]": "\(self.customerId)",
"filter[order]": "startDate DESC"
]
var success: SLSuccessBlock = {
(results: AnyObject!) in
var resultsArray = results as NSArray
var resultsMutableArray: NSMutableArray = NSMutableArray()
for result: AnyObject in resultsArray {
resultsMutableArray.addObject(result as NSDictionary)
}
self.tableData = resultsMutableArray
self.tableView.reloadData()
}
var failure: SLFailureBlock = {
(error: NSError!) -> () in
}
prototype.invokeStaticMethod("filter", parameters: params, success: success, failure: failure)
}
是否与使用方法名称“orders.prototype.customer”调用invokeInstanceMethod 有关?如何有效地组合呼叫?