Hello,
I have these two lists called db1
and db2
. db2
is the adjusted one after I have made changes and I want to update db1
without assigning db2
to db1
completely . Essentially, I want to only update the lists within the lists that differ between the two. There might be a point where the one is extraordinarily larger than the other (which my toy problem doesn't demonstrate) and I was just curious about best practices to update.
So in this example it should detect that v02
x
is different along with v02
having z
which did not exist for the other and then make those changes.
db1 <-
list(
"id" = "id",
"name" = "name",
"owner" = "",
"version" = list(
"v01" = list("desc" = list("name" = "v01",
"time" = Sys.time()),
"quest" = list(),
"x" = list(a = "a",b = "b",c = "c"),
"y" = list()),
"v02" = list("desc" = list("name" = "v02",
"time" = Sys.time()),
"quest" = list(),
"x" = list("b","e","f"),
"y" = list()))
)
db2 <-
list(
"id" = "id",
"name" = "name",
"owner" = "",
"version" = list(
"v01" = list("desc" = list("name" = "v01",
"time" = Sys.time()),
"quest" = list(),
"x" = list(a = "a",b = "b",c = "c"),
"y" = list()),
"v02" = list("desc" = list("name" = "v02",
"time" = Sys.time()),
"quest" = list(),
"x" = list("a","b","c"),
"y" = list(),
"z" = list(1:10000)))
)
Created on 2021-09-10 by the reprex package (v2.0.0)