I've been creating a database with Rethinkdb. Here is my database format:
{
"Email": [email protected], »
"Password": "totallyahash1234"
,
"UserName": "CoolDude3" ,
"id": "6a4bb963-687a-48c2-b3f0-2e91965d3515" ,
"Projects": {
"Project1": {
"Array1": [
{
"DataSet1": {
"Type": "12"
}
}
],
"Array2": [],
"Array3": []
}
}
}
And then I try to append Array 1 with:
r.table('users').filter(r.row("UserName").eq(UserName)).update(
{Projects: {Project1: {Array1:
r.row("Array1").default([]).append(NewDataSet)}}}
).run(connection, function(err, result) {
if (err) throw err;
console.log(JSON.stringify(result, null, 2));
});
But when I do I get an error which says:
"errors": 1,
"first_error": "No attribute Array1
in object:.
Yet this attribute clearly exists in the database. Please help :)
With r.row
you need to specify full path to Array1
:
r.table('users').filter(r.row("UserName").eq(UserName)).update(
{Projects: {Project1: {Array1:
r.row("Projects")("Project1")("Array1").default([]).append(NewDataSet)}}}
).run(connection, function(err, result) {
if (err) throw err;
console.log(JSON.stringify(result, null, 2));
});