I’m building an intranet system, where I have a form that allows to register new users, including uploading avatar photos, but when I create a new user and don’t upload any image, if I open the profile that I just created, the image that is linked to the Users collection gets all white, because the profilePhoto’s cell that belongs to the user is empty.
Is there a way to set a default image, so, if I don’t upload any photo, it loads a default image?
You put a DATASET-NAME/ID, but a COLLECTION-NAME is expected!
A DATASET is NOT-EQUAL —> DATABASE ! ! !
Run the following CODE…
import wixData from 'wix-data';
$w.onReady(()=>{
myFUNCTION();
})
function myFUNCTION(){
wixData.query("datasetLoggedUser")
.isEmpty("profilePhoto")
//.count() // <<<------- NOT sure if this can be used here!!!!
.find() // <<<------- Instead using this one.
.then( (results) => {console.log(results)
if(results.items.length > 0) {console.log("Existing items found")
$w("#text").text = "THERE IS A PHOTO"
}
else {$w("#text").text = "THERE IS NOT A PHOTO"}
})
}
Open your CONSOLE and take a look onto all the given RESULTS and informations!