Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

Return a record by it's name not Id

$
0
0

@mikeelemuel wrote:

Hi. I have this code that return a timeSlot record in a table and filter by from and zoneId and sorted by from. On, template.hbs there is dropdown selection that would display a certain record by it’s zoneID It is working fine and i have no problem with that.

However, is there any approach where i could return a record by it’s zone name? The purpose of returning a record by it’s name is because I would like to create a table that has a record of timeslot by it’s name in a different column.

My goal right now is to return something like that. When I selecte “All Zones” in a dropdown.

Here’s my code

model(params) {
    return this.store.query('zone', { sort: 'name' })
      .then((allZones) => {
        const zoneId = params.zoneId || allZones.get('firstObject.id');

        return Ember.RSVP.hash({
          zones:     allZones,
          zone:      this.store.findRecord('zone', zoneId),
          timeSlots: this.store.query('timeSlot', {
            'filter[from]':    params.from || moment().format('YYYY-MM-DD'),
            'filter[zone-id]': zoneId,
            'sort':            'from'
          }),
       });
    });
}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles