Project
I'm continuing my work building a reporting system for my students' Khan Academy data. See post about OAuth here: Oauth for Khan Academy API
I've built a data structure that I intend to update with new data I'll fetch from the Khan Academy API
Working data structure with sample student data (I typically render as a Dataset to view):
<|"studentKeys" ->
<|"ag5zfmtoYW4tY12345" -> <|"2017-08-04T17:11:38.000Z" -> <|"nickname" -> "Student, First",
"marks" -> <|"practiced" -> 0, "mastery1" -> 0,
"mastery2" -> 4, "mastery3" -> 152|>, "timeSpent" -> 456,
"percentageComplete" -> 77, "missionName" -> "algebra"|>|>,
"ag5zfmtoYW4tY12346" -> <|"2017-08-04T17:11:41.000Z" -> <|"nickname" -> "Student1, First1",
"marks" -> <|"practiced" -> 0, "mastery1" -> 0,
"mastery2" -> 0, "mastery3" -> 88|>, "timeSpent" -> 0,
"percentageComplete" -> 44, "missionName" -> "algebra"|>|>,
"ag5zfmtoYW4tY12347" -> <|"2017-08-04T17:11:42.000Z" -> <|"nickname" ->
"Student2,First2",
"marks" -> <|"practiced" -> 4, "mastery1" -> 2,
"mastery2" -> 0, "mastery3" -> 162|>, "timeSpent" -> 335,
"percentageComplete" -> 82, "missionName" -> "algebra"|>|>,
"ag5zfmtoYW4tY12348"-> <|"2017-08-04T17:11:44.000Z" -> <|"nickname" -> "Student3, First3",
"marks" -> <|"practiced" -> 0, "mastery1" -> 3,
"mastery2" -> 1, "mastery3" -> 142|>, "timeSpent" -> 1168,
"percentageComplete" -> 72, "missionName" -> "algebra"|>|>|>|>
Problem
I want to keep the data in the Wolfram Cloud and be able to update it. Is it possible to use a CloudObject? I'd really like to avoid having to deploy a relational database somewhere outside the Wolfram Cloud. Thanks.
Stuff I've tried
Databins worked, but they've got a 25kb limit so they won't scale.
Here's what I've tried:
demoDb = <|"studentKeys" -> \
<|"ag5zfmtoYW4tYWNhZGVteXJUCxIIVXNlckRhdGEiRnVzZXJfaWRfa2V5X2h0dHA6Ly9\
pZC5raGFuYWNhZGVteS5vcmcvYzRkZjBiODc4NjYzNDM0ZmJmODYyYmY4ZDcwYjE1MDIM"\
-> <|"2017-08-04T20:14:23.000Z" -> <|"nickname" -> "first, student",
"marks" -> <|"practiced" -> 0, "mastery1" -> 0,
"mastery2" -> 4, "mastery3" -> 152|>, "timeSpent" -> 456,
"percentageComplete" -> 77, "missionName" -> "algebra"|>|>,
"ag5zfmtoYW4tYWNhZGVteXJUCxIIVXNlckRhdGEiRnVzZXJfaWRfa2V5X2h0dHA6\
Ly9pZC5raGFuYWNhZGVteS5vcmcvYjM2MTViMjVjMTA4NDA1OWI0ZTY2Zjk2MzMwZWJhZD\
kM" -> <|"2017-08-04T20:14:24.000Z" -> <|"nickname" ->
"second, student",
"marks" -> <|"practiced" -> 0, "mastery1" -> 0,
"mastery2" -> 0, "mastery3" -> 88|>, "timeSpent" -> 0,
"percentageComplete" -> 44, "missionName" -> "algebra"|>|>,
"ag5zfmtoYW4tYWNhZGVteXJUCxIIVXNlckRhdGEiRnVzZXJfaWRfa2V5X2h0dHA6\
Ly9pZC5raGFuYWNhZGVteS5vcmcvYzdmY2U5NjY5OWFkNGQzODhiYTk0YmQwN2EwNDY4ZW\
MM" -> <|"2017-08-04T20:14:25.000Z" -> <|"nickname" ->
"third, student",
"marks" -> <|"practiced" -> 4, "mastery1" -> 2,
"mastery2" -> 0, "mastery3" -> 162|>, "timeSpent" -> 335,
"percentageComplete" -> 82, "missionName" -> "algebra"|>|>,
"ag5zfmtoYW4tYWNhZGVteXJUCxIIVXNlckRhdGEiRnVzZXJfaWRfa2V5X2h0dHA6\
Ly9pZC5raGFuYWNhZGVteS5vcmcvY2NjYjFhN2M3NTdjNGEzOGIwMDA3YTkyOWZiOWM2Ym\
YM" -> <|"2017-08-04T20:14:27.000Z" -> <|"nickname" ->
"fourth ,student",
"marks" -> <|"practiced" -> 0, "mastery1" -> 3,
"mastery2" -> 1, "mastery3" -> 142|>, "timeSpent" -> 1168,
"percentageComplete" -> 72,
"missionName" -> "algebra"|>|>|>|>;
(* AppendTo data in demoDb. Works fine here *)
AppendTo[demoDb["studentKeys"][
"ag5zfmtoYW4tYWNhZGVteXJUCxIIVXNlckRhdGEiRnVzZXJfaWRfa2V5X2h0dHA6Ly\
9pZC5raGFuYWNhZGVteS5vcmcvYzRkZjBiODc4NjYzNDM0ZmJmODYyYmY4ZDcwYjE1MDIM\
"],
<|"2017-08-04T20:18:23.000Z" -> <|"nickname" -> "first, student",
"marks" -> <|"practiced" -> 0, "mastery1" -> 0, "mastery2" -> 4,
"mastery3" -> 152|>, "timeSpent" -> 456,
"percentageComplete" -> 77, "missionName" -> "algebra"|>|>];
ce = CreateCloudExpression[demoDb];
(* AppendTo date in ce. Throws error *)
AppendTo[ce["studentKeys"][
"ag5zfmtoYW4tYWNhZGVteXJUCxIIVXNlckRhdGEiRnVzZXJfaWRfa2V5X2h0dHA6Ly\
9pZC5raGFuYWNhZGVteS5vcmcvYzRkZjBiODc4NjYzNDM0ZmJmODYyYmY4ZDcwYjE1MDIM\
"],
<|"2017-08-04T22:20:23.000Z" -> <|"nickname" -> "first, student",
"marks" -> <|"practiced" -> 0, "mastery1" -> 0, "mastery2" -> 4,
"mastery3" -> 152|>, "timeSpent" -> 456,
"percentageComplete" -> 77, "missionName" -> "algebra"|>|>];
Here is the error it throws:
Association::setps: <|ag5zfmtoYW4tYWNhZGVteXJUCxIIVXNlckRhdGEiRnVzZXJfaWRfa2V5X2h0dHA6Ly9pZC5raGFuYWNhZGVteS5vcmcvYzRkZjBiODc4NjYzNDM0ZmJmODYyYmY4ZDcwYjE1MDIM-><|2017-08-04T20:14:23.000Z-><|nickname->first, student,marks-><|practiced->0,mastery1->0,mastery2->4,mastery3->152|>,timeSpent->456,percentageComplete->77,missionName->algebra|>,2017-08-04T20:18:23.000Z-><|nickname->first, student,marks-><|practiced->0,mastery1->0,mastery2->4,mastery3->152|>,timeSpent->456,percentageComplete->77,missionName->algebra|>|>,<<1>>,<<1>>,ag5zfmtoYW4tYWNhZGVteXJUCxIIVXNlckRhdGEiRnVzZXJfaWRfa2V5X2h0dHA6Ly9pZC5raGFuYWNhZGVteS5vcmcvY2NjYjFhN2M3NTdjNGEzOGIwMDA3YTkyOWZiOWM2YmYM-><|2017-08-04T20:14:27.000Z-><|nickname->fourth ,student,<<3>>,missionName->algebra|>|>|> in the part assignment is not a symbol.
CloudExpression
. It's easily mutable by part, so you can easily add and update student data. $\endgroup$