-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
AfterSave BeforDelete does not update mongodb record on Server but works on Local Machine #2658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Not sure if you meant AFTER SAVE or beforeSave. In anycase, afterSave is async as we don't wait for the result of the afterSave to return unless you return a promise and only when that PR will land (#2499) in 2.2.19. In your beforeDelete, you should call
are completely async in your case and the deletion continue without waiting for it to complete. |
Thanks @flovilmart for the quick response, I also got similar issues with running this triggers on a Table that has an Image attachment. So how would I update my code to run promises? I tried using this and still no change. However it runs locally fine and updates MongoDB. Parse.Cloud.aferSave("Wallet", function(request, response) {
var currentUser = request.user;
var SyncTable = Parse.Object.extend("SyncTable");
var query = new Parse.Query(SyncTable);
query.equalTo("tableName",tableName);
query.equalTo("syncTableUser", currentUser);
Parse.Promise.when(query.first).then(function(res1){
res1.increment("version");
res1.set("isDelete", false);
res1.save();
}, function(e){
response.error();
})
}); Is there a fix before version 2.2.19 or just wait. |
If it works locally that's probably not an issue on parse-server but in your code. We don't provide code level support and this area is extensively tested. I suggest you reach out to a separate channel like stackoverflow for those implementation details. |
Ok could you share sample code on how a promise should be done for both afterSave and beforeDelete. I do think its the server but most likely not with my server but with the triggers and promises. |
AfterSave and BeforeDelete triggers updates records on my mongodb server when I run it locally but when I run the same code in the cloud it fails to update the record.In both cases Mongodb is running on a server. I am also triggering the record change via IOS parse SDK. I also do find that in the IOS terminal that it tries to reconnect to the server a bunch of times before working, however when I run the parse server locally I do not get the reconnect issues.
Steps to reproduce
Create a Cloud Code for beforeSave and aftersave
Run a simple IOS update or delete of a Class
Please include a detailed list of steps that reproduce the issue. Include curl commands when applicable.
BEFOREDELETE
SWIFT IOS CODE
Expected Results
MongoDB For bothe Local and Server Calls
SyncTable Should be AfterSave
version : 1 (incremented by 1)
isDelete : True
SyncTable Should be BeforeDelete
version : 1 (incremented by 1)
isDelete : False
Actual Outcome
MongoDB for Server
SyncTable Should be AfterSave
version : 0
isDelete : False
SyncTable Should be BeforeDelete
version : 0
isDelete : False
MongoDB for Local
SyncTable Should be AfterSave
version : 1
isDelete : True
SyncTable Should be BeforeDelete
version : 1
isDelete : False
Environment Setup
Logs/Trace
2016-09-04T19:35:50.522Z - afterSave triggered for Wallet
The text was updated successfully, but these errors were encountered: