Friday, 8 February 2019

Loopback (or similar) - how to create an API to return list of instances multiple Models

Hi all,I've been building a Loopback application (Loopback3) which has the following models:- NewsItem- UserAlertI need to develop an API where I can get the 10 most recent items between both NewsItems and UserAlerts.Can anyone suggest how this would be done using Loopback's ORM?I don't see any examples of this online, and some information points to writing raw SQL queries. I do see that I can create models that extend other models, using it as a base class.Ideally I would like to create a FeedItem model and have NewsItem and UserAlert extend the FeedItem base class, allowing me to somehow query FeedItem to get the 10 most recent items between NewsItem and UserAlert models.Realistically I'll need to add more business logic here but not sure where to start with this type of querying.Can anyone provide some direction here?Thank you :)

Submitted February 08, 2019 at 03:20PM by seventai

No comments:

Post a Comment