You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am not sure if this is related to ParseSwift of rather the Sever itself, but when I use following function in Cloud Code, my custom objectId is ignored upon saving a new document to database:
Parse.Cloud.beforeSave("PrsProfile", async (request) => {
if (request.original == null) {
//indexing to ElasticSearch before save to define ElasticSearch document id
const esResult = await elastic.indexProfile(request.object);
if (esResult != null) {
request.object.set("es", esResult);
const randomInt = Math.floor(Math.random() * (262144 - 1)) + 1; //bloom filter index in range 1...262144 (256*1024)
request.object.set("bf", randomInt);
request.log.info(`indexed new profile before saving to server database: ${esResult}}`);
} else {
throw "ElasticSearch ID was not defined, document was not saved and indexed";
}
}
});
As the function does not manipulate objectId neither the referred index function, I am a bit confused. Commenting out this trigger makes the custom objectId work well again. Also trigger "afterSave" does not break anything.
Just for completeness, here is the referred index function:
exports.indexProfile = async function(profile) { //PrsProfile
const currentLoc = new Parse.GeoPoint(profile.get("gp"));
const speakLangs = [];
const native = profile.get("nl");
const speak = profile.get("sl");
const learnLangs = profile.get("ll");
const trips = profile.get("gt");
if (native != null & Array.isArray(native)) {
speakLangs.push(...native);
}
if (speak != null & Array.isArray(speak)) {
speakLangs.push(...speak);
}
const { body } = await esClient.index({
id: profile.get("es"), //if null, then new index is created
index: "profile",
body: {
//TODO: check how updates are handeled
ag: profile.get("ag"),
gn: profile.get("gn"),
d: profile.get("d"),
o: profile.get("o"),
po: profile.get("po"),
sl: (speakLangs.length > 0 ? speakLangs : []),
ll: ((learnLangs != null & Array.isArray(learnLangs)) ? learnLangs : []),
gp: [currentLoc.latitude, currentLoc.longitude],
on: profile.get("on"),
da: profile.get("da"),
tn: profile.get("tn"),
tr: profile.get("tr"),
co: profile.get("co"),
gt: ((trips != null & Array.isArray(trips)) ? trips : []),
fd: profile.get("fd"),
bf: profile.get("bf") //bloom filter int value
}
})
//pass back an ES document id to be saved in MongoDB, if creating new
return body._id;
}
The text was updated successfully, but these errors were encountered:
As the function does not manipulate objectId neither the referred index function, I am a bit confused. Commenting out this trigger makes the custom objectId work well again. Also trigger "afterSave" does not break anything.
If commenting out the trigger allows your custom objectId to save correctly then it sounds like the issue is either with your cloud code or the server. I don't see the Swift Client SDK having any influence when it gets to your cloud code
Hello, I am not sure if this is related to ParseSwift of rather the Sever itself, but when I use following function in Cloud Code, my custom objectId is ignored upon saving a new document to database:
As the function does not manipulate objectId neither the referred index function, I am a bit confused. Commenting out this trigger makes the custom objectId work well again. Also trigger "afterSave" does not break anything.
Just for completeness, here is the referred index function:
The text was updated successfully, but these errors were encountered: