How do I use update async?

Currently, in my game players can like other players creations. I’m trying to use :UpdateAsync for saving likes because it queries with all servers

Although, my data looks something like this:

local Data = {
	Likes = 0,
	Followers = 0,
	LargeDataTable = {}
}

How would I use :UpdateAsync do only update the “Likes” part of my data?

Thanks!

update async requires a callback function, it should work with any data in a datastore. It can be quite complicated so read more about it on the api reference: GlobalDataStore:UpdateAsync

local function add_like(oldvalue, keyinfo)
    oldvalue.Likes += 1
    return oldValue, keyinfo:GetUserIds(), keyinfo:GetMetadata()
end

myDatastore:UpdateAsync("PlayerData", add_like)
1 Like