DB or not to DB?

HI! I have a client who would like to :

  1. I’d like users to be able to filter table results using 6 dropdowns ((dropdown A selection) AND (dropdown B selection) AND…) www.whitecoatwork.com/docjobs2 2. I’d like to calculate data from two columns into another column within #docjobs collection: (docCoverageDay) + (paNpCoverageDay) = (totalCoverageDay). 3. I’d like forms to autofill logged-in user info (name, email address…)

Would this be possible in Wix DB for instance?

Please check out this cool website created with wix code - https://www.chickadeefilms.com/michigan-talent-database

You can certainly do the filtering, here’s an example of a three level filter where the Cemetery is selected (CemeteryDD) first, then a section (SectionDD) based on which cemetery was selected, then a row (RowDD) within the section. The Section and Row dropdowns are disabled until a cemetery has been selected and row is disabled until a section is selected.

The change_event sections are triggered when a value is selected from the relevant dropdown.

import wixData from ‘wix-data’;

$w.onReady(function () {
$w(“#CemeteryDD”).enable();
$w(“#SectionDD”).disable();
$w(“#RowDD”).disable();
$w(“#dataset1”).onReady(() => {

	wixData.query("Cemeteries") 
		.limit(200) 
		.find() 
		.then(results => { 
			const uniqueTitles = getUniqueTitles(results.items); 
			$w("#CemeteryDD").options = cemeteryOptions(uniqueTitles); 
			$w("#CemeteryDD").enable(); 
		}); 

	function getUniqueTitles(items) { 
		const titlesOnly = items.map(item => item.title); 
		return [...new Set(titlesOnly)]; 
	} 

	function cemeteryOptions(uniqueList) { 
		return uniqueList.map(curr => { 
			return { 
				label: curr, 
				value: curr 
			}; 
		}); 
	} 
}); 

});

export function CemeteryDD_change(event, $w) {
$w(“#SectionDD”).disable();
$w(“#RowDD”).disable();
wixData.query(“Cemeteries”)
.limit(1000)
.eq(“title”, $w(“#CemeteryDD”).value)
.find()
.then(results => {
const uniqueBlocks = getUniqueBlocks(results.items);
$w(“#SectionDD”).options = blockOptions(uniqueBlocks);
$w(“#SectionDD”).enable();
});

function getUniqueBlocks(items) { 
	const blocksOnly = items.map(item => item.block); 
	return [...new Set(blocksOnly)]; 
} 

function blockOptions(uniqueList) { 
	return uniqueList.map(curr => { 
		return { 
			label: curr, 
			value: curr 
		}; 
	}); 
} 

}

export function SectionDD_change(event, $w) {
wixData.query(“Cemeteries”)
.limit(200)
.eq(“title”, $w(“#CemeteryDD”).value)
.eq(“block”, $w(“#SectionDD”).value)
.find()
.then(results => {
const uniqueRows = getUniqueRows(results.items);
$w(“#RowDD”).options = rowOptions(uniqueRows);
$w(“#RowDD”).enable()
});

function getUniqueRows(items) { 
	const rowsOnly = items.map(item => item.row); 
	return [...new Set(rowsOnly)]; 
} 

function rowOptions(uniqueList) { 
	return uniqueList.map(curr => { 
		return { 
			label: curr, 
			value: curr 
		}; 
	}); 
} 

}

export function RowDD_change(event, $w) {
$w(“#dataset1”).setFilter(wixData.filter()
.eq(“cemetery”, $w(“#CemeteryDD”).value)
.eq(“block”, $w(“#SectionDD”).value)
.eq(“row”, $w(“#RowDD”).value)
);
}