lundi 19 septembre 2016

Create multiple db entries based on a variable in Ember

I'm a new to Ember and am having a really hard time with this problem. I'm building an app that manages beer tap lists. Each bar has a different number of taps.

I take the number of taps in the new bar signup = orgTap

On the first login to the dashboard I want to have an empty line for each tap and a db entry created to correspond to each tap.

The code I have is:

export default Ember.Route.extend({

    model(params) {
        return this.get('store').findRecord('bis', params.bis_id);
    },


actions: {

    generateTapList(orgTap, id){
        var store = this.store;
        let tapOwner = this.get('store').peekRecord('bis', id);
        const taps = this.get('orgTap');
        let i = orgTap;

        const newTap = store.createRecord('taplist', {
                bis: tapOwner,
                    
                        tap: "Tap" + i,
                        i = i - 1;
                    
            });

        newTap.save();
    },
}   
});

I have installed ember-truth-helpers thinking it may help with the loop.

Side Question -- Am I stupid for trying to learn Ember for my first app after a full stack dev class?? I feel that everything I just learned is irrelevant to how Ember works.




Aucun commentaire:

Enregistrer un commentaire