Hi everyone, I got a strange problem, tried to make an additional database with user emails and some info about them, so 1st step was to check if it has already email in it. Used query, .eq and .find to search for it and it not working at all, I put toInsert.whois = something(found, not found, err) in all possible places which could query run and none of them run, it’s always write in database standard “b4 run” which is set before query should works. The second part with .insert is working nice.
import wixData from ‘wix-data’;
$w.onReady( function () {
});
export function button1_click(event) {
const mail = $w(‘#text1’).text;
let toInsert = {
“title”: mail,
};
toInsert.whois = “b4 run”;
wixData.query(“AdditionalMembersInfo”)
.eq(“title”, mail)
.find()
.then( (results) => {
if (results.items.length > 0) {
toInsert.whois = “found”;
let firstItem = results.items[0]; //see item below
} else {
toInsert.whois = “not found”;
}
} )
. catch ( (err) => {
toInsert.whois = “err”;
let errorMsg = err;
}
);
wixData.insert(“AdditionalMembersInfo”, toInsert)
.then( (results) => {
let item = results; //see item below
}
)
. catch ( (err) => {
let errorMsg = err;
}
);
//Add your code for this event here:
}