5

How can I translate the following SQL query to RQL?

Select bike.* from Bike 
inner join Appointment on Bike.BikeID = Appointment.BikeID and
                          Appointment.Status != 'Booked'

I know that in Mongo it is possible to filter by related documents.

However, RavenDB documentation says that:

It's important to remember that the load clause is not a join; it's applied after the query has already run and before we send the interim results to the projection for the final result. Thus, it can't be used to filter the results of the query by loading related documents and filtering on their properties.

So what is the correct way to run such a query in RavenDB?

Danielle
  • 3,324
  • 2
  • 18
  • 31
rafalxyz
  • 159
  • 1
  • 6
  • 2
    Did you see this article about intersection? It does involve creating an index but then you can filter. https://ravendb.net/docs/article-page/5.2/Csharp/indexes/querying/intersection – Danielle Jul 11 '21 at 07:15
  • Thanks for answer. It works for that query but what if I have to search by many properties of related document? Let's say I have Order with OrderLine collection. OrderLine contains id of Product. Product has many properties, let's say 30. In some order report user needs to filter by all of these properties. I'd have to put all Product data into index to make it work but I don't know if it's a good idea. I'm used to SQL indexes with small number of columns. – rafalxyz Jul 11 '21 at 11:46

0 Answers0