Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11631

RethinkDB branch / do +"Argument 1 to deleteAt may not be `undefined`."

$
0
0

I am trying to write some somewhat complicated ReQL that deletes a single value from an array in a field, or deletes the record entirely if that value is the only one in the array.

I thought I had worked it out using branch/do/offsetAt, but then I ran into this "Argument 1 to deleteAt may not be undefined." error and I'm at a loss as to what the fix is.

r.branch(    r.db('db').table('table').get('uuid').eq(null),    {"deleted": 0, "errors": 0, "inserted": 0, "replaced": 0, "skipped": 0, "unchanged": 1},    r.db('db').table('table').get('uuid').getField('array_field').eq(['value']),    r.db('db').table('table').get('uuid').delete(),    r.do(        r.db('db').table('table').get('uuid').getField('array_field').offsetsOf('value'),        function(index) {            return r.branch(                index.eq([]),                {"deleted": 0, "errors": 0, "inserted": 0, "replaced": 0, "skipped": 0, "unchanged": 1},                r.db('db').table('table').get('uuid').update({"array_field": r.row('array_field').deleteAt(index[0])                })            )        }    ))

Also, as a side question, is there a more efficient way to do this without constantly fetching the record over and over calling .get()


Viewing all articles
Browse latest Browse all 11631

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>