Skip to content
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

Migrating Cloud Code hangs on await query.find #5238

Closed
haroot opened this issue Dec 14, 2018 · 2 comments
Closed

Migrating Cloud Code hangs on await query.find #5238

haroot opened this issue Dec 14, 2018 · 2 comments

Comments

@haroot
Copy link

haroot commented Dec 14, 2018

THe below code hangs on the const user = await query1.get / find etc segment. if i put console.log after it won't log because the async function is not resolved... worked fine on parse 2.8.3

Parse.Cloud.define('exportData', async (req, res) => {
console.log("req params:", req.params, req.params.parseUserId);
if (!_.has(req.params, 'parseUserId')) {
return;
}
try {
console.log("At exportData");
//Export data from User and JournalEntry Collection
var id = req.params.parseUserId;
var query1 = new Parse.Query(Parse.User);
var query2 = new Parse.Query("JournalEntry");
var query3 = new Parse.Query("Timeline");
query2.equalTo("user", { "__type": "Pointer", "className": "_User", "objectId": id });
query3.equalTo("user", { "__type": "Pointer", "className": "_User", "objectId": id });
console.log("queries, ", query1, query2, query3, id, user); // does not work after consts
const user = await query1.get(id, { useMasterKey: true });
const journal = await query2.find({ useMasterKey: true });
const timeline = await query3.find({ useMasterKey: true });
console.log("Exporting user", id, user, journal, timeline);
//res.success("Exported User Data Successfully for " +user.get('email'));
console.log("Exporting PRO Status:", user.get("isPro"));
if ( user.get("isPro") == true ) {
await makeProPdf(user, journal, timeline);
}
else {
await makeFreePdf(user, journal, timeline);
}
} catch (err) {
//$res.error("Error:", err);
return err;
}
//return user.get('email');
});

@flovilmart
Copy link
Contributor

Please use stackoverflow for implementation related question, or open a PR with a failing test.

@haroot
Copy link
Author

haroot commented Dec 14, 2018

solution is:
const user = await query1.get(id, { useMasterKey: true }); =>
const user = await query1.get(id);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants