GETTING DATASET DOES NOT EXIST WITH THIS CODE.
wixdata.query("DSCI") .eq("title", userEmail) .find() .then( (results) => { if (results.items.length > 0) { $w('#text46').text = "In >0 area" // set sessions for display of user in the header of pages session.setItem(MKUserRole, userrole); session.setItem(MKUserEmail, userEmail); $w("#BackMember").show(); }else{ // The email is not in the ds so add them to the ds. $w('#text45').text = "In 0 area" $w("#DSCI").setFilter( wixdata.filter() .eq("title", "")); $w("#DSCI").setFieldValue("title", userEmail); $w("#DSCI").setFieldValue("abilites", "Member"); $w("#containNewMember").show() ; $w("#BackMember").show(); }; })
@raymondtrussell123 The reason for the error is that you are attempting to use setFilter directly on a collection and not a dataset that you have added to the page that has been linked to that collection.
Though it seems like you should be able to do what you are attempting, it can be tricky mixing wixData.query code with dataset code. It can take a while to figure out the best use of each when you are new to Velo, but in this case, I would opt for a wixData API approach using wixData.insert to add the record if needed. If you then need to filter on the newly added record, you could then use the dataset setFilter command.
I have no idea where you calling the above code, so I took the liberty to do it in the page onReady.
import wixData from 'wix-data'; $w.onReady(function () { wixData.query("DSCI") .eq("title", userEmail) .find() .then( (results) => { if (results.items.length > 0) { $w('#text46').text = "In >0 area" // set sessions for display of user in the header of pages session.setItem(MKUserRole, userrole); session.setItem(MKUserEmail, userEmail); $w("#BackMember").show(); } else { $w('#text45').text = "In 0 area" let toInsert = {"title": userEmail,"abilites": "Member"} wixData.insert("DSCI",toInsert) .then( (results) => { $w("#containNewMember").show(); $w("#BackMember").show(); // Now, that record has been added via wixData insert, you can // filter the dataset on the page that is set to the // collection that you have named DSCI. $w("#dataset1").setFilter(wixData.filter() .eq("title", userEmail)); } ); }; }) });
When you want to reference a dataset in code, you use the ID highlighted in this screen shot: