I am trying to pull an object made from a function that was stored on code.org data section.
I have attached my code, commented the output and referred to the debug view on my table.
I do not know if this is a limitation of the current impelentation of readRecord or a lack of my ability to accurately reference the object.
The only Object method available is .keys(), .values was not available.
Is there a way to access the contents of an object using readRecords?
var assn1 = new ASSIGNMENT("Work", {"val":80,"weight":0.2});
function ASSIGNMENT (name, grade){
this.name = name;
this.grade = grade;
}
//createRecord("mytable", {assn:assn1}, function() {});
readRecords("mytable", {}, function(records) {
console.log(records); //[{"assn":{},"id":1},{"assn":{},"id":2}]
console.log(records[0]); //{"assn":{},"id":1}
console.log(records[0].id); //1
console.log(records[0].assn); //{}
console.log(Object.keys(records[0].assn)); //["name","grade"]
});
/**
* Contents of debug view on "mytable"
[
{
"assn": {
"name": "Work",
"grade": {
"val": 80,
"weight": 0.2
}
},
"id": 1
},
{
"assn": {
"name": "Work",
"grade": {
"val": 80,
"weight": 0.2
}
},
"id": 2
}
]
*/