I am slowly loosing my mind I hope someone can help me. So… long story short I am trying to create my own Club registration process for some clubs in my social club.
A- privatemembersdata collection links to 1425memberDetails (image1) by “logged in email”
B- 1425MemberDetails links to Club-Details by (“Club-Details-1”)
so every member may sign up for multiple clubs
C- Club-Details has all the information on each club
The problem has been when I create the sign up form for the Clubs.
Form A- Clubs Detail All ( click sends the user to Clubs Detail (Club)
Form B Clubs Detail Club ( club info)
Form C- So Here I am giving them the option to go and correct their information on file “edit personal info” (separate form not a problem)
OR continue to click the “Join Now” button for this club.
I want the name of this club to be inserted into 1425MemberDetails / Club-Details-1 field. I guess via update so it doesn’t delete any other club’s names.
This is where the problem is. The code I have used for insert creates a new record - not what I want.
import wixData from 'wix-data';
$w.onReady(function () {
// TODO: write your page related code here...
});
export function submit_click(event, $w) {
let toInsert = {
"clubs": $w("#clubName").text,
};
wixData.insert("1425MemberDetails", toInsert)
.then( (results) => {
let item = results;
$w('#success').text.show();
} )
.catch( (err) => {
let errorMsg = err;
$w('#failed').text.show();
} );
// wixData.insert("1425ClubDetails", toInsert)
// .then( (results) => {
// let item = results;
// } )
// .catch( (err) => {
// let errorMsg = err;
// } );
}
The code I have for update doesn’t work.
import wixData from 'wix-data';
let thisEmail = $w("#loginEmail").text;
let thisMember = $w("#membersName").text;
let thisClub = $w("#clubName").text;
export function submit_click(event, $w) {
wixData.query("1425MemberDetails")
.eq("loginEmail", thisEmail)
.eq("name", thisMember)
.eq("club", thisClub)
.find()
.then((results) => {
if (results.items.length > 0) {
let item = results.items[0];
item.clubs = thisClub; // updated club
wixData.update("1425MemberDetails", item);
$w('#success').text.show();
console.log(results.items);
} else {
// handle case where no matching items found
}
})
.catch((err) => {
$w('#failed').text.show();
let errorMsg = err;
});
}
Can somebody please help me to keep my hair!!!
Thank you
Sylvia