#StackBounty: #loopback4 Loopback 4: How to query an array of objects

Bounty: 300

I have been unable to query objects based on a property in an array of objects.

I am trying to query all orders that have the event with id 7:

  const orders = await this.orderRepository.find({where: {events: {elemMatch: {'id': event.id}}}});

The above gives me the following error:

 ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''{"id":"7"}

If i try the following filter, I always get an empty array back:

{where: {events: {like: '%id%'}}}

What is the correct approach for Loopback 4?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.