How to save dataStore Changes in Tables?

hello i have a module script that datastores. however if i were too add or change anything in the table it wouldnt load the new values and keep the data stored ones. i want to achieve is being able to load new values or changed values that are added to my table without resetting all the data. How would i do this?

– module script

	local unlockedModule = {}

	local datastoreService = game:GetService("DataStoreService")
	local unlockedData = datastoreService:GetDataStore("new")

	unlockedModule.itemStats = {
		["apple"] = {
			locked = true,
			image = "rbxassetid://5673482401"
		},
		["gold bar"] = {
			locked = true,
			image = "rbxassetid://18336886764"
		},
		["painting"] = {
			locked = true,
			image = "rbxassetid://18367945834"
		},
		["stolen bank info"] = {
			locked = true,
			image = "rbxassetid://18336886764"
		},
		["flower pot"] = {
			locked = true,
			image = "rbxassetid://18336886764"
		},
	}

	function unlockedModule:saveData(player, itemStats)
		local success, errorMessage = pcall(function()
			unlockedData:SetAsync(player.UserId .. "-unlockedStats", itemStats)
		end)

		if not success then
			warn("Failed to save unlocked items " .. errorMessage)
		end
	end

	function unlockedModule:loadData(player)
		local success, unlockedStatsTable = pcall(function()
			return unlockedData:GetAsync(player.UserId .. "-unlockedStats")
		end)

		if success and unlockedStatsTable then
			return unlockedStatsTable
		else
			if not success then
				warn("Failed to load weapon damage: " .. unlockedStatsTable)
			end
			return unlockedModule.itemStats
		end
	end

function unlockedModule:getItemAttribute(player, name, attribute)
	local unlockedItemStats = self:loadData(player)

	if unlockedItemStats[name] then
		return unlockedItemStats[name][attribute] or unlockedModule.itemStats[name][attribute]
	else
		return unlockedModule.itemStats[name][attribute]
	end
end

	function unlockedModule:updateItemAttribute(player, name, attribute, value)
		local unlockedItemStats = self:loadData(player)

		if not unlockedItemStats[name] then
			unlockedItemStats[name] = {}
		end

		unlockedItemStats[name][attribute] = value

		self:saveData(player, unlockedItemStats)
	end

	unlockedModule.lockedItems = {}
	unlockedModule.unlockedItems = {}

	function unlockedModule:getUnlockedItems(player)
		local itemStatsTable = self:loadData(player)
		self.unlockedItems = {} -- Reset table

		for name, attributes in pairs(itemStatsTable) do
			if attributes["locked"] == false then
				table.insert(self.unlockedItems, name)
			print("unlocked: " ..name)
			end
		end
		
		return self.unlockedItems

	end

	function unlockedModule:getLockedItems(player)
		local itemStatsTable = self:loadData(player)
		self.lockedItems = {} -- Reset table

		for name, attributes in pairs(itemStatsTable) do
			if attributes["locked"] == true then
				table.insert(self.lockedItems, name)
				print("locked: " .. name)
			end
		end

		return self.lockedItems
	end

	function unlockedModule:unlockItem(player, itemName)
		local itemStatsTable = self:loadData(player)
		
		if itemStatsTable[itemName]["locked"] == true then
			itemStatsTable[itemName]["locked"] = false
			table.remove(self.lockedItems, itemName)
			table.insert(self.unlockedItems, itemName)
		end
	end


	return unlockedModule

Hello, I have looked over your script and I think I found ways to save dataStore changes in tables.

1: Instead of saving the entire itemStats table, you can only save the specific changes that you made.

2: Change the updateItemAttribute to save the updated unlockedItemStats table by updating only the specific attribute/value that has changed.

Try these two solutions and if they don’t work then tell me.