dimanche 1 avril 2018

How to push or update data with emberfire?

My guess was to put the model (in my case 'user') inside => type, but then it'll say "Assertion failed, you need to pass a model ..."

I do have a user.js in app/models

here's an excerpt from the router (after login function)

self.store.push({
                data: {
                    id: data.currentUser.uid,
                    type: 'user',
                    attributes: {
                        displayName: data.currentUser.displayName,
                        email: data.currentUser.email,
                        photoURL: data.currentUser.photoURL,
                        firebaseUID: data.currentUser.uid,
                        rank: "scorer",
                        status: "active",
                        loginCount: 0,
                        provider: provider,
                        timestamp: new Date().getTime()
                    }
                }
            });

and here's my model (user.js in app/models)

import DS from 'ember-data';

export default DS.Model.extend({
  displayName: DS.attr('string'),
  email: DS.attr('string'),
  photoURL: DS.attr('string'),
  firebaseUID: DS.attr('string'),
  rank: DS.attr('string'),
  status: DS.attr('string'),
  loginCount: DS.attr('string'),
  provider: DS.attr('string'),
  timestamp: DS.attr('number')
});

Please help :( thanks everyone in advance!




Aucun commentaire:

Enregistrer un commentaire