在 Parse 中保存多个对象需要 1 个以上的 API 请求? [英] Saving multiple objects in Parse taking more than 1 API request?

查看:22
本文介绍了在 Parse 中保存多个对象需要 1 个以上的 API 请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我从 Parse 文档和 Stack OverflowPFObject.saveAllInBackground 只需要 1 个 API 请求即可保存所有对象.
我的方法保存了一个对象,然后返回并saveAlls 两个对象.这似乎只需要 2 个 API 请求,但是 Parse Analytics 告诉我它需要 3 个.
有什么猜测吗?这是代码:

From what I can tell from the Parse docs and Stack Overflow, the PFObject.saveAllInBackground will only require 1 API request to save all the objects.
My method saves an object, then comes back and saveAlls 2 more objects. This seems like it should take only 2 API requests, however Parse Analytics is telling me that it is taking 3.
Any guesses? Here is the code:

         // Create new Vote object
            var voteObject = PFObject(className: "Votes")
            [.....]

            voteObject.saveInBackgroundWithBlock {
                (succeeded: Bool!, error: NSError!) -> Void in
                if (succeeded == true){

                  // Add relation for postObject
                    self.postObject.relationForKey("UserVotes").addObject(voteObject)

                  // Add relation for user object
                    PFUser.currentUser().relationForKey("userVotes").addObject(voteObject)

                    PFObject.saveAllInBackground([self.postObject, PFUser.currentUser()], block: {
                        (succeeded: Bool!, error: NSError!) -> Void in
                        [.....]
                    })

推荐答案

saveAll 方法不再算作 1 个 API 调用.现在,对于保存的每个对象,它计为 1 个 API 调用.请参阅此处了解更多信息:stackoverflow.com/q/25690439/3344977

The saveAll method no longer counts as 1 API call. It now counts as 1 API call for EACH object being saved. See here for more info: stackoverflow.com/q/25690439/3344977

这篇关于在 Parse 中保存多个对象需要 1 个以上的 API 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆