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 9279275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:35:34+00:00 2026-06-18T17:35:34+00:00

I am iterating over a moment-range daterange and trying to insert documents. I am

  • 0

I am iterating over a moment-range daterange and trying to insert documents. I am getting the following error:

Exception while simulating the effect of invoking '/carpool_events/insert' 
Error
 Error: Sorting not supported on Javascript code
    at Error (<anonymous>)
    at Object.LocalCollection._f._cmp     (http://localhost:3000/packages/minimongo/selector.js?    5b3e1c2b868ef8b73a51dbbe7d08529ed9fb9951:251:13)
    at Object.LocalCollection._f._cmp     (http://localhost:3000/packages/minimongo/selector.js?    5b3e1c2b868ef8b73a51dbbe7d08529ed9fb9951:226:36)
    at LocalCollection._f._cmp (http://localhost:3000/packages/minimongo/selector.js?5b3e1c2b868ef8b73a51dbbe7d08529ed9fb9951:218:33)
    at _func (eval at <anonymous> (http://localhost:3000/packages/minimongo/sort.js?08a501a50f0b2ebf1d24e2b7a7f8232b48af9057:63:8), <anonymous>:1:51)
    at Function.LocalCollection._insertInSortedList     (http://localhost:3000/packages/minimongo/minimongo.js?7f5131f0f3d86c8269a6e6db0e2467e28eff6422:616:9)
    at Function.LocalCollection._insertInResults (http://localhost:3000/packages/minimongo/minimongo.js?7f5131f0f3d86c8269a6e6db0e2467e28eff6422:534:31)
    at LocalCollection.insert (http://localhost:3000/packages/minimongo/minimongo.js?7f5131f0f3d86c8269a6e6db0e2467e28eff6422:362:25)
    at m.(anonymous function) (http://localhost:3000/packages/mongo-livedata/collection.js?3ef9efcb8726ddf54f58384b2d8f226aaec8fd53:415:36)
    at http://localhost:3000/packages/livedata/livedata_connection.js?77dd74d90c37b6e24c9c66fe688e9ca2c2bce679:569:25 

This is my loop with the insert. I have tested the loop by just writing to console.log instead of inserting and the loop works fine

    'click button.save-addEventDialogue': function(e, tmpl) {

          var start = Session.get("showAddEventDialogue_dateRangeStart");
          var end = Session.get("showAddEventDialogue_dateRangeEnd");
          var dateRange = moment().range(moment(start),moment(end));
          var dateLoopIncrement = moment().range(moment(start),moment(start).add('days',1));

          console.log(dateRange);
          console.log(dateLoopIncrement);

          // Loop through the date range
          dateRange.by(dateLoopIncrement, function(moment) {
            // Do something with `moment`
            var dateToSave = dateRange.start;  

        // Insert the record
            Carpool_Events.insert({
                       owner: Meteor.user().profile.name,
                       owner_id: Meteor.userId(),
                       original_owner: Meteor.user().profile.name,
                       original_owner_id: Meteor.userId(),
                       declined: 0,
                                  date: dateToSave.toDate()
                      });
            dateToSave.add('days',1);
         });            

         // Clear the Session
         Session.set("showAddEventDialogue_dateRangeStart","");
         Session.set("showAddEventDialogue_dateRangeEnd","");

         // Close the dialogue
         Session.set("showAddEventDialogue", false);
       } 

What is the right way to do this? Thanks.

  • 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-18T17:35:35+00:00Added an answer on June 18, 2026 at 5:35 pm

    The error message Sorting not supported on Javascript code is a result of inserting a JavaScript function (!) into a collection — for example, by doing something like Carpool_Events.insert({x: function () { ... }}); JavaScript functions should not normally go into collections.

    Somewhere in your code there is probably a typo where you are not calling a function (for example, writing Meteor.userId on the client instead of Meteor.userId().) My guess would be that in the process of making your code run on the server, you coincidentally fixed or avoided this.

    I wasn’t able to visually find the problem in your code — if I’m wrong, to make more progress it would be helpful to have a reproduction.

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

Sidebar

Related Questions

I have the following issue related to iterating over an associative array of strings
When iterating over a large array with a range expression, should I use Python's
When iterating over the following generator expression, fun(i) for i in mylist if i
Iterating over all sheets in a Spreadsheet I ran into this error message: Unable
When iterating over a standard container, do you think it's a good idea to
I'm iterating over a JRE Collection which enforces the fail-fast iterator concept, and thus
I want avoid iterating over a nil array. My bad solution: if nil!=myArr myArr.each
Is there a better shorter way than iterating over the array? int[] arr =
Starting from Visual Studio 2010, iterating over a set seems to return an iterator
I need a function, which is capable of iterating over the collection, calling a

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.