I have been successfully using the database collection and user input properties on my website pages for the last few months. Since yesterday, neither of the two sites that I am currently working on allow for me to create new connections to the datasets.
I have checked all the relevant permissions, nothing has been changed and the connections with the user input fields that I had created before yesterday evening continue to work. Only new connection that I am trying to create do not work.
Have just checked to see what happens if you change permission from Read & Write to Write Only to the dataset - when it is Write Only, then it allows for user to input in preview mode, but when permission set to Read & Write, it does not allow user to input anything in preview mode?
Managed to work around the above issue by typing into the sandbox version of the database for the dynamic page to display first and then the user input fields began to work as expected. However, there must be an underlying is with the collection now as when I have added a member login button to query the data in that collection and insert the email into the collection, I keep getting a validation error.
The code I have used is as below and works as expected on another one of my sites.
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
export function button1_onclick() {
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w(“#button1”).label = “Login/Sign Up”;
$w(“#button2”).hide();
} );
}
// user is logged out
else {
let userId;
let userEmail;
// prompt the user to log in
wixUsers.promptLogin( {"mode": "login"} )
.then( (user) => {
userId = user.id;
return user.getEmail();
} )
.then( (email) => {
// check if there is an item for the user in the collection
userEmail = email;
return wixData.query("Profiles")
.eq("_id", userId)
.find();
} )
.then( (results) => {
// if an item for the user is not found
if (results.items.length === 0) {
// create an item
const toInsert = {
"_id": userId,
"email": userEmail
};
// add the item to the collection
wixData.insert("Profiles", toInsert)
.catch( (err) => {
console.log(err);
} );
}
// update buttons accordingly
$w("#button1").label = "Logout";
$w("#button2").show();
} )
.catch( (err) => {
console.log(err);
} );
}
}
export function button2_onclick() {
wixLocation.to(/Profiles/Update/${wixUsers.currentUser.id});