Skip to content

Instantly share code, notes, and snippets.

@ahmadajmi
Last active August 29, 2015 14:05
Show Gist options
  • Save ahmadajmi/2d2afb740534d69b84e8 to your computer and use it in GitHub Desktop.
Save ahmadajmi/2d2afb740534d69b84e8 to your computer and use it in GitHub Desktop.
M101JS :: HOMEWORK 2.2 in CoffeeScript
express = require 'express'
app = express()
mongo = require 'mongodb'
mongo.connect 'mongodb://127.0.0.1/weather', (err, db) ->
cusror = db.collection('data').find().sort("State": 1, "Temperature": -1);
state = ''
operator = {'$set':{'month_high':true}}
cusror.each (err, doc) ->
if doc == null
return db.close()
else if doc.State != state
state = doc.State
db.collection('data').update {'_id': doc._id}, operator, (err, updated) ->
console.log('updated')
app.listen('8080')
console.log('started at 8080')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment