Im trying to create a custom user collection so I can customize it more.
to do so, I created a CustomUser collection with a ‘user’ reference field that references to the standard user collection (OneToOne relationship). I want to create a afterInstert hook to the PrivateMembersData collection, which will create a custom user every time a user registers to the platform and set the user
field on that custom user to the regular user.
I have this:
import wixData from 'wix-data';
export function Members$PrivateMembersData_afterInsert(item, context) {
console.log("in before insert");
wixData.insert('CustomUsers', {'user': item.id}).then( (res) => {
console.log("in hook after insert");
console.log(res);
console.log(context);
} );
return item;
}
but its not working. I thought it was a problem with promises so I also tried:
import wixData from 'wix-data';
export async function Members$PrivateMembersData_afterInsert(item, context) {
console.log("in before insert");
await wixData.insert('CustomUsers', {'user': item.id}).then( (res) => {
console.log("in hook after insert");
console.log(res);
console.log(context);
} );
return item;
}
but that didnt work either.