logo
down
shadow

[METEOR $addToSet]Cannot insert into object '$addToSet' is empty


[METEOR $addToSet]Cannot insert into object '$addToSet' is empty

By : user2954231
Date : November 22 2020, 01:01 AM
hope this fix your issue For me it looks like you didnt add field profile.photos at register. You do it with method Accounts.onCreateUser It looks like this
code :
Accounts.onCreateUser(function(options,user){
  user.profile:{
  photos:[]
  }
})


Share : facebook icon twitter icon
MongoDB Cannot apply $addToSet to non-array in Meteor JS

MongoDB Cannot apply $addToSet to non-array in Meteor JS


By : user3282852
Date : March 29 2020, 07:55 AM
this will help You should have looked at the document you created. That is not how you notate an empty array for serializing in JSON notation. You should have done:
code :
var post = {
  yak: $(e.target).find('[name=yak]').val(),
  submitted: new Date(),
  score: 0,
  users: []
};
"users" : {  }
Meteor.users : $addToset in Profile [nested object]

Meteor.users : $addToset in Profile [nested object]


By : wisanggeni
Date : March 29 2020, 07:55 AM
wish of those help If you want profile.subscription.streets and profile.subscription.users to be each be an array of ids, then you should update the user's document like this:
code :
Meteor.users.update(Meteor.userId(), {
  $addToSet: {
    'profile.subscription.streets': streetId,
    'profile.subscription.users': userId
  }
});
Meteor & Mongo: addToSet inserting

Meteor & Mongo: addToSet inserting


By : user3524503
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Do you mean every card has id and image field? I guess so.
You can add nested object to an array fields. Like that
Why my document update in meteor method with $addToSet do nothing?

Why my document update in meteor method with $addToSet do nothing?


By : Azizz San
Date : March 29 2020, 07:55 AM
This might help you OK, I found my stupid mistake ! I had to do: Meteor.call('joinTopic', topicId);
instead of: Meteor.call('joinTopic', { topicId: topicId });
meteor array $addToSet not adding any items

meteor array $addToSet not adding any items


By : Lidley Pierre
Date : March 29 2020, 07:55 AM
like below fixes the issue I figured out the issue. I forgot that the scope of 'this' changes in the inline 'instrArray.forEach' function, making this.userId 'undefined'. The Profiles collection was unable to find the record. I changed the following code:
code :
let instrArray = instruments.split(',');
instrArray.forEach(function(instrument){
  instrument = instrument.trim();
  Profiles.update({ userId: this.userId }, { $addToSet: { instruments: instrument } });
});
let userId = this.userId;
let instrArray = instruments.split(',');
instrArray.forEach(function(instrument){
    instrument = instrument.trim();
    Profiles.update({ userId: userId }, { $addToSet: { instruments: instrument }     });
});
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org