简体   繁体   中英

Rethinkdb Append says attribute doesn't exist when it does

I've been creating a database with Rethinkdb. Here is my database format:

{

"Email": blah@blah.com, »
"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));
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM