Parse-sdk-js: No Response when using Parse.Object.saveAll()

Created on 11 Aug 2016  路  7Comments  路  Source: parse-community/Parse-SDK-JS

  • parse-server version 2.2.17

There is No Response when use Parse.Object.saveAll() to save Members: Array()

// @params MembersArray
// about 68 records in this Array

Parse.Object.saveAll(MembersArray, {
success: function(objs) {
            console.log(objs)
            console.log("DONE!")
            // no done occurred...
},
error: function(err) {
            console.log(err)
            console.log("ERROR!")
            // no error occurred...
        }
});

But it works when I use MembersArray.forEach(m=>(m.save)).

let count =0
 MembersArray.forEach(m=>{
            m.save().then(data=>{
                        count++
                        console.log("Progress",count," of ", Members.length)
                        if(count == Members.length){
                                                console.log("All Done!")
                        }
            })
})

log like this

Progress 1 of 68
Progress 2 of 68
Progress 3 of 68
......
Progress 68 of 68
All Done!

I'm Shocked! save() one-by-one works, But take me about 2 minites to save 68 records to mongodb.

resolved

Most helpful comment

@suathh I'm using mongoose lib for temporary, there are methods to handle multi save & update.
But it's need you to write custom RESTful API for access mongodb directly.

I hope parse-server will support these feature for mongodb.

All 7 comments

When you run saveAll, can you confirm which network requests are actually sent? SaveAll tries to attempt batches of 20 objects, so ideally you should see 4 different network requests.

@andrewimm I run this in server-end node script, I don't know how to see requests of batches.
how to dump all of this requests to debug?

I use this and get nothing:

httpry -i eno1

where did saveAll() send post requests to? my parse-server or mongodb?
If that, I think I should write an request function using REST API, instead of saveAll(), for temprary?

The SDK sends requests to your parse-server, it doesn't know anything about your backing database.

Unfortunately, I don't know anything about your specific setup, so I can't provide any deeper advice on how to debug your network connection. Some well-placed logging or debugger breakpoints might help, but I can't do much without a reproducible case or a stack trace

I belive this problem is still alive I have 2-4k objects to update and a new save for each of 2-4k objects. This takes about 50-80mins to complete.
I am doing this in that way.

guessQuery.each(

    function(guessItem){   

      return processGuess(guessItem,match_result,match_home_score,match_away_score);

    }

And processGuess function returns

  return guessResult.save().then(

        function(guessResult){

          guess.set("checked",true);

          return guess.save(); } 

Before I was doing this with promises arrays Parse.promise.when() but it not seems to be working correctly because I was getting multiple same records and non-updated records.

Is there any better way to do this ?

Thanks.

@suathh I'm using mongoose lib for temporary, there are methods to handle multi save & update.
But it's need you to write custom RESTful API for access mongodb directly.

I hope parse-server will support these feature for mongodb.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jlnquere picture jlnquere  路  4Comments

Jonarod picture Jonarod  路  6Comments

simpleshadow picture simpleshadow  路  6Comments

dplewis picture dplewis  路  7Comments

REPTILEHAUS picture REPTILEHAUS  路  7Comments