Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9175743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:58:03+00:00 2026-06-17T16:58:03+00:00

I am following the recently published book Getting Started with Meteor.js JavaScript Framework by

  • 0

I am following the recently published book “Getting Started with Meteor.js JavaScript Framework” by Isaac Strack. The book works with Meteor 0.5.0. I am working with version 0.5.4.

In the book you build an app with a few categories to which you insert data for tracking household items, and who they may be lent to. I deployed the app to a meteor subdomain, and it is working perfectly. It does not replicate my local MongoDB error.

LendLib

I am in Chapter 5, and I have just removed autopublish from the app, and specified my local channels for data.

Locally, under the under the “Tools” category only, when I try to add a new item to the category, I recieve this error in my browser console:

Exception while simulating the effect of invoking '/Lists/update' Error {} Error: Cannot apply $addToSet modifier to non-array
    at Error (<anonymous>)
    at LocalCollection._modifiers.$addToSet (http://localhost:3000/packages/minimongo/modify.js?e7f02f0df0bff9f0b97236f9548637b7ede1ac74:178:13)
    at Function.LocalCollection._modify (http://localhost:3000/packages/minimongo/modify.js?e7f02f0df0bff9f0b97236f9548637b7ede1ac74:53:9)
    at LocalCollection._modifyAndNotify (http://localhost:3000/packages/minimongo/minimongo.js?7f5131f0f3d86c8269a6e6db0e2467e28eff6422:474:19)
    at LocalCollection.update (http://localhost:3000/packages/minimongo/minimongo.js?7f5131f0f3d86c8269a6e6db0e2467e28eff6422:444:12)
    at m.(anonymous function) (http://localhost:3000/packages/mongo-livedata/collection.js?3ef9efcb8726ddf54f58384b2d8f226aaec8fd53:415:36)
    at http://localhost:3000/packages/livedata/livedata_connection.js?367884963b120d457819216ff713b2586b266dde:540:25
    at _.extend.withValue (http://localhost:3000/packages/meteor/dynamics_browser.js?46b8d1f1158040fcc2beb7906ec2f932871a398d:21:19)
    at _.extend.apply (http://localhost:3000/packages/livedata/livedata_connection.js?367884963b120d457819216ff713b2586b266dde:539:47)
    at Meteor.Collection.(anonymous function) [as update] (http://localhost:3000/packages/mongo-livedata/collection.js?3ef9efcb8726ddf54f58384b2d8f226aaec8fd53:266:23) logging.js:30
update failed: Internal server error logging.js:30

The tools category already has one item in it which was submitted earlier in the tutorial. If I type into the console lists.findOne({Category:"Tools"}); I get the output which recognizes an item in the Object:

Object
  Category: "Tools"
  _id: "eaa681e1-83f2-49f2-a42b-c6d84e526270"
    items: Object
      LentTo: "Steve"
      Name: "Linear Compression Wrench"
      Owner: "me"
      __proto__: Object
  __proto__: Object

However, the screen output is blank:

enter image description here

Naturally I have tried restarting the meteor server & shut down the browser, but no resolution. I am new to MongoDB, so I am unclear as to where to turn to understand what is causing this problem, or why.

You can view the app here. You can view the code on my GitHub.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:58:04+00:00Added an answer on June 17, 2026 at 4:58 pm
    function addItem(list_id, item_name) {
        if(!item_name && !list_id)
          return;
        lists.update({_id:list_id}, {$addToSet:{items:{Name:item_name}}});
      }
    

    Seems like you’re trying to add an object to a set. You’re getting an error on simulation. Let’s investigate that error. The code that errors out:

    https://github.com/meteor/meteor/blob/master/packages/minimongo/modify.js

     $addToSet: function (target, field, arg) {
        var x = target[field];
        if (x === undefined)
          target[field] = [arg];
        else if (!(x instanceof Array))
          throw Error("Cannot apply $addToSet modifier to non-array");
        else { ...
    

    Uh oh, throw Error("Cannot apply $addToSet modifier to non-array.").

    Look at your code:

    Object
      Category: "Tools"
      _id: "eaa681e1-83f2-49f2-a42b-c6d84e526270"
    ...
      items: Object
    ...
    

    items is an object, not an array! It will error out.

    Can you $addToSet to an object with Mongo? Let’s look at the code.

    https://github.com/mongodb/mongo/blob/4a4f9b1d6dc79d1ba4a7d7eaa9e4eb6d00aa466c/db/update.cpp

     case ADDTOSET: {
                uassert( 12592 ,  "$addToSet can only be applied to an array" , in.type() == Array );
                ...
            }
    

    Nope! This is from old Mongo code, because the contemporary codebase is sprawling, but same thing.

    I only found one insert in your code.

    'keyup #add-category': function(e, t) {
      if (e.which === 13) {
        var catVal = String(e.target.value || "");
        if (catVal) {
          lists.insert({Category:catVal});
          Session.set('adding_category', false);
        }
      }
    },
    

    Try lists.insert({Category:catVal,items:[]}). So that items is initialized as an array rather than an object when it was first used.

    Also, I don’t think $addToSet compares objects in an array the way you would like anyway, so consider making a separate collection Items that contains a categoryId.

    It is purely a coincidence that it is working on one place and not another.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code recently started returning empty strings. It works on other systems, so
I recently came across the following line of code in a JavaScript book that
Recently the PHP manual started showing the following warning on every mysql function page:
I have recently started using Netbeans with following stack Liferay, icefaces with jBoss. Is
I'm running Visual Studio 2005 Pro, and have been getting the following error recently:
I have recently started following the examples from The Little Schemer and when trying
I recently started following the online course on iPhone development from Stanford University on
I recently came across following syntax of Entity Framework. Notice the where clause -
so recently ive rebuilt my site following Google's AJAX Crawling methods. Everything works fine
Recently I've started following a pre-existing project based on ASP.NET 3.5. Now, I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.