I have a similar issue, but am checking to see if the current item in the dataset has an image instead of a document. I modified the code from @stcroppe, but the site is not collapsing the blank images.
import wixData from 'wix-data';
$w("#dataset1").onReady(() => {
let currentItem = $w('#dataset1').getCurrentItem();
console.log(currentItem);
let hasImage = currentItem.hasOwnProperty('image');
console.log("image "+(hasImage?"exists":"does not exist"));
// Does the data set include a cvURL property for the current item?
if (hasImage) {
$w("#serviceImage").show();
console.log("document found");
} else {
$w("#serviceImage").collapse();
console.log("no document found");
}
console.log(hasImage);
});