--[[
	Returns all children instances of parent that pass specified property criteria.
]]

function DataModelUtils.getChildrenWithCriteria(parent, criteria)
	local results = {}
	for _, child in ipairs(parent:GetChildren()) do
		local isMatch = true
		for property, value in pairs(criteria) do
			local success, result =
				pcall(
				function()
					return child[property] == value
				end
			)
			if not (success and result) then
				isMatch = false
				break
			end
		end
		if isMatch then
			table.insert(results, child)
		end
	end
	return results
end

return DataModelUtils
