how to query across relationships

I'm trying to find all events that are hosted in restaurants close to the user, I tried the following:
const eventos = await this.repositorioEvento.find({
where: gte(ev.fecha, new Date().toISOString().split('T')[0]),
with: {
local: {
where: and(
lte(locales.latitud, boundaries.northEast.lat),
lte(locales.longitud, boundaries.northEast.lng),
gte(locales.latitud, boundaries.southEast.lat),
lte(locales.longitud, boundaries.southEast.lng),
lte(locales.latitud, boundaries.northWest.lat),
gte(locales.longitud, boundaries.northWest.lng),
gte(locales.latitud, boundaries.southWest.lat),
gte(locales.longitud, boundaries.southWest.lng),
),
columns: {
nombre: true,
direccion: true,
latitud: true,
longitud: true,
},
},
},
});
const eventos = await this.repositorioEvento.find({
where: gte(ev.fecha, new Date().toISOString().split('T')[0]),
with: {
local: {
where: and(
lte(locales.latitud, boundaries.northEast.lat),
lte(locales.longitud, boundaries.northEast.lng),
gte(locales.latitud, boundaries.southEast.lat),
lte(locales.longitud, boundaries.southEast.lng),
lte(locales.latitud, boundaries.northWest.lat),
gte(locales.longitud, boundaries.northWest.lng),
gte(locales.latitud, boundaries.southWest.lat),
gte(locales.longitud, boundaries.southWest.lng),
),
columns: {
nombre: true,
direccion: true,
latitud: true,
longitud: true,
},
},
},
});
but the local value on eventos comes up null. how can I make a query have its where clause across the joined table?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?