I am a newbee in Node.js development and trying to figure out how to reach a clean way to list records in a page with Nunjucks template .
So, when rendering my nunjucks page receive two objects One of them is a Brand listing like
[
{ BrandId: 4, BrandName: 'Fiat' },
{ BrandId: 5, BrandName: 'Mercedes' },
{ BrandId: 6, BrandName: 'BMW' },
{ BrandId: 7, BrandName: 'Chevrolet' },
{ BrandId: 8, BrandName: 'Jaguar' },
{ BrandId: 9, BrandName: 'Toyota' },
{ BrandId: 10, BrandName: 'Renault' },
{ BrandId: 11, BrandName: 'Peugeot ' }
]
Another object is called services and to build the page i use a for loop to list services properties .
{% for service in services %}
<tr>
<td>{{service.ServiceId}}</td>
<td>{{service.ServiceName}}</td>
<td>{{service.BrandId}} </td>
<td>{{service.VehicleName}}</td>
<td>{{service.ServicePrice}}</td>
<td>
As you can See... I have BrandId in my services object ... so what I would like is recover the BrandName from brands object that I have ...
I have tried apply selectattr filter ... but do not seems to work Do you have any idea on how I can acomplish that ? thanks in advance