Question

Nodejs situation:

r.db('users').get('e@mai.l').without(['password']).run()

If user doesn't exist rethinkdb will throw an error

-- 2014-01-22T13:26:04.720Z [20163] [ ctx error ] --
RqlRuntimeError: Cannot perform without on a non-object non-sequence `null`. in:
r.table('users').get('e@mai.l').without(['password'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Questions:

  1. Why does Rethink throws errors instead of returning them in callback's first arg?
  2. Why does it throw error anyway? Can't it just return null in the end and complete request?
Was it helpful?

Solution

The error should be returned in the first argument of the callback.

It returns an error because you are trying to remove a field from a null object. RethinkDB throws an error like when Node tries to access a field of null.

To avoid the error you can do r.table("users").get("e@mai.l").default({}).without('password')

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top