0

I have a table (in a RethinkDB database) that has a bunch of documents with the field VIN0. This field almost always stores numbers, as intended.

I had some data corruption recently where there are some strings in place of numbers for the field VIN0. Queries I was using to manipulate this data now return the error: "e: Expected type NUMBER but found STRING in:"

I'd like to filter for the strings, but I can't seem to find them. Is there a way to use something like Number.isInteger() to filter out these items within RethinkDB?

Thanks!

Jorge Silva
  • 4,574
  • 1
  • 23
  • 42

1 Answers1

3

You can use typeOf to find type of a field, or a element. Let's say you want to filter document with VIN0 is a number

r.db('db').table('table').filter(r.row('VIN0').typeOf().eq('NUMBER'))

You can also try to correct problem by using coereTo to convert string to number.

r.db('db').table('table')
  .filter(r.row('VIN0').typeOf().eq('STRING'))
  .update({VIN0: r.row('VIN0').coerceTo('NUMBER')}) 

Hope this helps.

kureikain
  • 2,304
  • 2
  • 14
  • 9