Created
          April 10, 2013 22:58 
        
      - 
      
 - 
        
Save drnikko/5359189 to your computer and use it in GitHub Desktop.  
    Stores a word and a number. I use it to count the number of times a certain word is used in a meeting.
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # The word you want to add to, and the optional number to add to it. | |
| mongo --eval "var theword='solve', thecount=5" write.js | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | connection = new Mongo("localhost"); | |
| db = connection.getDB("jargon"); | |
| coll = db.getCollection("words"); | |
| if (thecount === undefined) { | |
| thecount = 1; | |
| } | |
| coll.update({"word" : theword }, | |
| { $inc: { "count": thecount } }, | |
| {upsert: true} | |
| ); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment