Skip to content

Instantly share code, notes, and snippets.

@drnikko
Created April 10, 2013 22:58
Show Gist options
  • Save drnikko/5359189 to your computer and use it in GitHub Desktop.
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.
# The word you want to add to, and the optional number to add to it.
mongo --eval "var theword='solve', thecount=5" write.js
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