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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:14:37+00:00 2026-05-30T15:14:37+00:00

I am trying my hand at learning node.js using coffeescript but am having trouble

  • 0

I am trying my hand at learning node.js using coffeescript but am having trouble wrapping my head around the flow.

My first task is to parse a csv file and add the parsed records to mongodb. Here is what I have thus far:

https://gist.github.com/1953474

I used a simple counter var that the addRule function increments on invocation and decrements at the end of the callback, checking to see if it was the last to finish so exit can be called. I think this is correct form but if there is a more proper way I am open to suggestion.

The real problem I am having is that nothing gets parsed or added to the database. Initially I realized I wasn’t waiting for the connection to be established but now I am stumped. I’m wondering if I’ve just missed some detail regarding how I should be working with mongoose…

Ideas?

  • 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-05-30T15:14:39+00:00Added an answer on May 30, 2026 at 3:14 pm

    Your counter specifically has two bugs.

    Your not calling exit if the number of records is zero.

    And your decrementing after rather then before. n_out-- returns n_out, --n_out returns n_out - 1

    Your other mistake is using CoffeeScript, you’ll regret that.

    addRules = (records) ->
      n_out = 1
      next = () ->
        if --n_out is 0
          exit()
      next()
      addRule = (r) ->
        n_out++
        util.print n_out
        Rule.update {state: r.state}, r, {upsert: true}, (err) ->
          if err
            util.print r.state + ": " + err + "\n"  
          else 
            util.print "processed " + r.state + " rule\n"
          next()
      addRule(r) for r of records 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I'm a C# guy trying my hand at learning C. As a first
I'm trying my hand in learning Regular Expressions in Oracle ( rather, my first
Hurro! I'm trying my hand at writing my first Android app, and I've hit
I'm trying to create a GUI using Java by hand-coding it (without using GUI
I'm experienced with iOS development, but I'm trying my hand at MacOS development tonight.
I'm trying my hand at google appengine and using the datastore with php and
I've recently started learning/using django; I'm trying to figure out a way to have
I'm learning Matplotlib, and trying to implement a simple linear regression by hand. However,
After trying my hand at Perl and a little bit of C, I am
I'm trying my hand at behavior driven development and I'm finding myself second guessing

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.