I made a simple after insert hook to check the collection item against another collection. When it runs, it hits the true statement of if function and everything is fine, but the collection is not updated. I think i missed something simple or I have a basic lack of understanding of javascript… either or.
here is my code:
import wixData from ‘wix-data’;
export function EventReg_afterInsert(item, context) { let userEmail = item.email;
console.log(userEmail);
wixData.query(“Members”).eq(“email”, userEmail).find()
.then((results) => { if (results.items[0].member === true ) {
item.member = true ;
console.log(“member set to true”);
console.log(item);
}
}) return item;
}
I also tried before insert - the console logs showing that the member field is true, but it doesn’t register in the collection. I must be missing something basic - thank you in advance for any insights.
import wixData from ‘wix-data’;
export function EventReg_beforeInsert(item, context) { let userEmail = item.email;
console.log(userEmail);
wixData.query(“Members”).eq(“email”, userEmail).find()
.then((results) => { if (results.items[0].ismgbMember === true ) {
item.member = true ;
console.log(“member set to true”);
console.log(item);
}
}) return item;
}