Reputation: 61
I have three, near identical, nested arrays - ar1 and ar3 are owned by teams working on a project. ar2 is meant to be the "overview", gathering changes as they happen.
Each team can update only their part of the array. ar1 updates ar1[1] and ar1[2], ar3 updates ar3[3] and ar4[4].
I'd like ar2 to occasionally gather all of the changes, and push them out to both arrays (so each team is updated on the others progress)
ar1 = [[id1, **red, apple,** foo, car]
[id2, **yellow, lemon,** rar, bar]
ar2 = [[id1, red, apple, boo, mario]
[id2, yellow, lemon, star, tim]]
ar1 = [[id1, blue, banana, **boo, mario**]
[id2, blue, tomato, **star, tim**]
The arrays end up on Google Sheets via Google scripts, if you'd like the context.
So my question - I've been working with for loops up until this point, to make sure everyone has new projects as they come in (and filtering out duplicates). But using nested for loops at this point would increase the workload by a lot - we're talking about thousands of projects.
Is there a faster way of working through this? Each project has a unique ID which may help.
Upvotes: 1
Views: 63
Reputation: 61
I was shooting myself in the foot here by not learning databases - for anyone in the future coming here, this is the wrong way to go about it!
(Plenty of 'for' statements will do the trick, comparing UIDs, but just getting a simple mySQL will help you much better).
Upvotes: 0
Reputation: 686
Use objects {}
instead of arrays for the data-management stage, and if the consumer (Google Sheets) requires the data to be in arrays, you can make a function that takes the objects and maps them to arrays of the format you require.
Upvotes: 2