0

I am trying to append an object into an array in rethink. Here is how I am trying to append it:

rethink('shifts')
        .get(shiftId)
        .update(row => row("milestones").default([]).append({
            dateAchieved: date,
            phaseType: phasetype.toUpperCase()
        })).run(rethinkConnection)

The error I get is this:

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ReqlQueryLogicError: Expected type TABLE but found DATUM:
"shifts" in:
r("shifts").get("5d1b607f-e670-4eb5-b873-6e800f8ae8f8").update(function(var_15) { return var_15("milestones").default([]).append({"dateAchieved": r.ISO8601("2012-04-12T06:00:00.000Z"), "phaseType": "PILOT"}); })
  ^^^^^^^^  

What does it mean that it is expecting a 'TABLE', but found a 'DATUM'? How do I get this to insert an object into the array?

jhamm
  • 24,124
  • 39
  • 105
  • 179
  • Possible duplicate of [Why can't I append an object to an array in rethinkdb?](https://stackoverflow.com/questions/47725272/why-cant-i-append-an-object-to-an-array-in-rethinkdb) – Vincent Cantin Mar 10 '18 at 15:45

1 Answers1

2

You need to do

rethink.table(“shifts”)

Calling the rethink namespace with a string just returns an expression

vbranden
  • 5,814
  • 2
  • 22
  • 15