在Parse中保存多个对象需要多于1个API请求

在Parse中保存多个对象需要多于1个API请求

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

问题描述

从Parse docs和, PFObject.saveAllInBackground 只需要1个API请求来保存所有对象。
我的方法保存一个对象,然后返回 saveAll 另外两个对象。这似乎只需要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调用。现在它被视为保存EACH对象的1个API调用。有关详细信息,请参阅此处:

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请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 03:45