Closed BannerBomb closed 2 years ago
@BannerBomb You should use functional query like .filter(i => ({ roboboard: i('something') }))
. rethinkdb doen't have the scope in r
execution, thats why you need to directly declare a variable to be used.
I just ran into this issue as well.
const allDocuments = await r.table(tableName)
.filter(
// THIS SHOULD WORK B/C THE DATA EXPLORER HAS NO PROBLEM WITH IT
// ERROR: Cannot use r.row in nested queries. Use functions instead
r.row("name").match(`^${query.startsWith}`).and(r.row("tier").eq(query.tier))
)
.orderBy(r.asc("created"))
.limit(limit)
.run(databaseConnection);
Interestingly, trying out your solution gave the same error:
.filter(_ => ({
name: r.row("name").match(`^${query.startsWith}`),
tier: r.row("tier").eq(query.tier)
}))
Thats totally not what I have suggested. I have advised to use the i
argument, though you just skip it and continue using the r
.filter(i => ({
name: i("name").match(`^${query.startsWith}`),
tier: i("tier").eq(query.tier)
}))
About an error itself- it will take a time to turn out why it is handled as an error. I am not quite good at understanding how to resolve it, but that's an issue so I'll mention it while continue researching the code. So for now you can use the solution above, I don't see any potential issues for you.
Ah, thanks for the corrected code. I no longer get an issue but I also don't get any documents returned.
I was looking through the code and I have no idea what to look for either. I'll keep looking as well though.
When I throw i
into a console.log
I get a bunch of functions that are exposed by r
, I believe:
[Function] {
term: [ 10, [ 1 ] ],
toString: [Function],
run: [AsyncFunction],
getCursor: [AsyncFunction],
do: [Function],
table: [Function],
get: [Function],
getAll: [Function],
eq: [Function],
ne: [Function],
lt: [Function],
le: [Function],
gt: [Function],
ge: [Function],
not: [Function],
add: [Function],
sub: [Function],
mul: [Function],
div: [Function],
mod: [Function],
floor: [Function],
ceil: [Function],
round: [Function],
append: [Function],
prepend: [Function],
difference: [Function],
setInsert: [Function],
setIntersection: [Function],
setUnion: [Function],
setDifference: [Function],
slice: [Function],
skip: [Function],
limit: [Function],
offsetsOf: [Function],
contains: [Function],
getField: [Function],
keys: [Function],
values: [Function],
hasFields: [Function],
withFields: [Function],
pluck: [Function],
without: [Function],
merge: [Function],
between: [Function],
reduce: [Function],
map: [Function],
fold: [Function],
filter: [Function],
concatMap: [Function],
orderBy: [Function],
distinct: [Function],
count: [Function],
isEmpty: [Function],
union: [Function],
nth: [Function],
innerJoin: [Function],
outerJoin: [Function],
eqJoin: [Function],
zip: [Function],
insertAt: [Function],
deleteAt: [Function],
changeAt: [Function],
spliceAt: [Function],
coerceTo: [Function],
typeOf: [Function],
update: [Function],
delete: [Function],
replace: [Function],
insert: [Function],
tableCreate: [Function],
tableDrop: [Function],
tableList: [Function],
config: [Function],
status: [Function],
wait: [Function],
reconfigure: [Function],
rebalance: [Function],
sync: [Function],
grant: [Function],
indexCreate: [Function],
indexDrop: [Function],
indexList: [Function],
indexStatus: [Function],
indexWait: [Function],
indexRename: [Function],
branch: [Function],
or: [Function],
and: [Function],
forEach: [Function],
info: [Function],
match: [Function],
upcase: [Function],
downcase: [Function],
sample: [Function],
default: [Function],
toISO8601: [Function],
toEpochTime: [Function],
inTimezone: [Function],
during: [Function],
date: [Function],
timeOfDay: [Function],
timezone: [Function],
year: [Function],
month: [Function],
day: [Function],
dayOfWeek: [Function],
dayOfYear: [Function],
hours: [Function],
minutes: [Function],
seconds: [Function],
group: [Function],
sum: [Function],
avg: [Function],
min: [Function],
max: [Function],
split: [Function],
ungroup: [Function],
changes: [Function],
toGeojson: [Function],
distance: [Function],
intersects: [Function],
includes: [Function],
getIntersecting: [Function],
fill: [Function],
getNearest: [Function],
polygonSub: [Function],
toJSON: [Function],
toJsonString: [Function],
setWriteHook: [Function],
getWriteHook: [Function],
bitAnd: [Function],
bitOr: [Function],
bitXor: [Function],
bitNot: [Function],
bitSal: [Function],
bitShl: [Function],
bitSar: [Function],
bitShr: [Function],
[Symbol(RethinkDBQuery)]: true
}
EDIT: It's the same as exposing the document in the filter function actually.
This is just a query builder object instance; you won't receive a document that way. Any console.logs server side are not sent to the rethinkdb, executed and returned back, it's not working that way. All you do with r.[command]
stuff is you generate a query, which is sent server side and then wait for data being return. So you might have an issue with the conditions you provide
I'm just passing plain strings, idk what's going on.
This is quite not related to a current issue, I think it'ld be easier if you ask it in the help channel in clack
I did that first actually, before coming here. I'll just close this. Finally looking into Postgres instead.
Doing something like this
using this package seems to give me the error
but running the exact same script with the dataexplorer works perfectly fine :thinking: