I am using Ember with Firebase. I am trying to update two user's friends' lists when an action is executed. The way the model's work is that is each user belongs to a friendsList. Each friendsList has many friends (which are users). However when I run this code, I get the error:
currentFriendsList.save is not a function
Any ideas why this is happening?
Here is the code:
var userId = this.controllerFor('teams/new').get('userId');
let currentUser = this.get('user').get('currentUser');
let myUser = this.get('store').peekRecord('user', currentUser.id);
let actorName = myUser.get('name');
if (userId != null){
let selectedUser = this.get('store').peekRecord('user', userId);
let selectedFriendsList = selectedUser.get('friendsList');
let currentFriendsList = myUser.get('friendsList');
selectedFriendsList.get('friends').pushObject(myUser);
currentFriendsList.get('friends').pushObject(selectedUser);
currentFriendsList.save().then(() =>
selectedFriendsList.save());
Here is the friendslist model:
user: DS.belongsTo('user', { inverse: 'friendsList' }),
friends: DS.hasMany('user')
Here is the applicable part of the user model:
friendsList: DS.belongsTo('friendslist', { inverse: 'user' })
Aucun commentaire:
Enregistrer un commentaire