Arrays stored in data storage

I know that I can store an array in’s data storage, but can readRecords pull an array out of a column?

If you want to record and retrieve arrays in the data backend you’ll need to encode it as JSON. So when recording, use JSON.stringify(my_array) and then when retrieving you can decode that JSON string with JSON.parse(my_array). Here’s a quick example that that stores an array to a key/value pair and then immediately retrieves it

1 Like

Thank you, that was a perfect solution.
The same process can for more complicated objects as well.
var assn1 = new ASSIGNMENT(“Work”, {“val”:80,“weight”:0.2});
var assnCopy;
function ASSIGNMENT (name, grade){ = name;
this.grade = grade;

createRecord("mytable", {data:JSON.stringify(assn1)}, function() {});
readRecords("mytable", {}, function(records) {
  console.log(records[2].data); //{"name":"Work","grade":{"val":80,"weight":0.2}}
  assnCopy = JSON.parse(records[2].data);