Reputation: 1169
Is it possible to compare the function of an existing index with an ordinary native function in JavaScript?
For instance, I might create an index with the following code:
r.table('Table').indexCreate('index', document => document.hasFields('field'));
I might then, later, wish to determine whether the index has the same function:
document => document.hasFields('field')
Using indexStatus()
, two properties may be able to help with this.
First, function
is a Buffer
representing the function, and can be compared with Buffer
s obtained from other indexStatus()
objects. However, it's not clear how this could be compared with a native JavaScript function. A new index could be created, and then its Buffer
compared with the Buffer
of the existing index, but this would be a messy and performance-impacting workaround.
Second, query
is a string
containing a function resembling that which was provided to indexCreate()
. However, this property seems to be undocumented, and the value is not always exactly the same as the function provided to indexCreate()
, with changes to variable names and the transformation of arrow functions to function expressions. I've written some rough code which tries to work with this approach, although it's imperfect, given the opaque nature of the rules by which the query
value is generated by RethinkDB.
Upvotes: 0
Views: 163