1

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
                        [.....]
                    })
Community
  • 1
  • 1
dcgoss
  • 2,147
  • 3
  • 20
  • 31
  • Your `voteObject` also gets saved. Are you sure the count doesn't include that too? – rickerbh Dec 12 '14 at 02:53
  • @rickerbh believe it includes that. Logically, wouldn't it be one save for the voteObject, and one save for the two objects in the saveAll? – dcgoss Dec 12 '14 at 02:55
  • Yes, you're right - silly me. I just tried the same thing. Created 5 PFObjects, saved them with a saveAllInBackground and watched network traffic. There is definitely only 1 network request being made. However, my analytics API hit increased by 5. I guess it's quicker/more reliable from a client perspective as a single request has to go, but it appears you don't actually save API hits. What a scam! – rickerbh Dec 12 '14 at 03:13
  • If you look right at the end of the REST operations API documentation with their [batch command](https://parse.com/docs/rest#objects-batch) (which is how I'd assume `saveAll` is implemented under the hood) it states "_Note that N requests sent in a batch will still count toward your request limit as N requests._" – rickerbh Dec 12 '14 at 03:21
  • @rickerbh Very strange. I am curious (if what you say is true) why most people are saying it only takes one request. Could perhaps the saveAll method (in theory) have some special tag that differs from a batch that tells Parse to only count it as one request? If only we had Hector Ramos here to save the day... – dcgoss Dec 12 '14 at 03:27
  • @Hector Ramos worth a shot! – dcgoss Dec 12 '14 at 03:28
  • For anyone looking at this, 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: http://stackoverflow.com/q/25690439/3344977 – user3344977 Jan 24 '16 at 06:00

1 Answers1

0

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

Community
  • 1
  • 1
user3344977
  • 3,584
  • 4
  • 32
  • 88