Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var fn, mongo_driver;

({
  _houston_setupNewCollection: function(name) {
    var e, key, user, value;
    if (!this.userId) {
      return;
    }
    user = Meteor.users.findOne(this.userId);
    if (!(user != null ? user.profile.admin : void 0)) {
      return;
    }
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        console.log(e);
      }
      return set_up_collection(name, collections[name]);
    }
  }
});

fn = Meteor.bindEnvironment(save_collections, function(e) {
  return console.log(e);
});

// MongoInternals is the 'right' solution as of 0.6.5
mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;

mongo_driver.mongo.db.collections(fn);

// publish our own internal state
Meteor.publish('_houston', function() {
  if (Meteor.users.findOne({
    _id: this.userId,
    'profile.admin': true
  })) {
    return Houston._collections.find();
  }
});

Meteor.publish('_houston_adminUser', function() { // used by login page to see if admin has been created yet
  return Meteor.users.find({
    'profile.admin': true
  }, {
    fields: {
      'profile.admin': true
    }
  });
});
```

Response:
_houston_setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e

        set_up_collection(name, collections[name])

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.find()

Meteor.publish '_houston_adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
_houston_setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e

        set_up_collection(name, collections[name])

Response:
fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.find()

Meteor.publish '_houston_adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Response:
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["admin_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["admin_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["admin_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "admin_#{name}", (sort, filter, limit) ->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["admin_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["admin_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["admin_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "admin_#{name}", (sort, filter, limit) ->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e
```

Response:
var Dummy, collections, root;

root = typeof exports !== "undefined" && exports !== null ? exports : this;

Dummy = new Meteor.Collection("system.dummy"); // hack.

collections = {
  'users': Meteor.users
};

Meteor.startup(function() {
  var set_up_collection;
  return set_up_collection = function(name, collection) {
    var methods;
    methods = {};
    methods[`admin_${name}_insert`] = function(doc) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      return collection.insert(doc);
    };
    methods[`admin_${name}_update`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.update(id, update_dict);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.update(id, update_dict);
      }
    };
    methods[`admin_${name}_delete`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.remove(id);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.remove(id);
      }
    };
    Meteor.methods(methods);
    return Meteor.publish(`admin_${name}`, function(sort, filter, limit) {
      var e;
      if (Meteor.users.findOne({
        _id: this.userId,
        'profile.admin': true
      })) {
        try {
          return collection.find(filter, {
            sort: sort,
            limit: limit
          });
        } catch (error) {
          e = error;
          return console.log(e);
        }
      }
    });
  };
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var Dummy, collections, root;

root = typeof exports !== "undefined" && exports !== null ? exports : this;

Dummy = new Meteor.Collection("system.dummy"); // hack.

collections = {
  'users': Meteor.users
};

Meteor.startup(function() {
  var set_up_collection;
  return set_up_collection = function(name, collection) {
    var methods;
    methods = {};
    methods[`admin_${name}_insert`] = function(doc) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      return collection.insert(doc);
    };
    methods[`admin_${name}_update`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.update(id, update_dict);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.update(id, update_dict);
      }
    };
    methods[`admin_${name}_delete`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.remove(id);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.remove(id);
      }
    };
    Meteor.methods(methods);
    return Meteor.publish(`admin_${name}`, function(sort, filter, limit) {
      var e;
      if (Meteor.users.findOne({
        _id: this.userId,
        'profile.admin': true
      })) {
        try {
          return collection.find(filter, {
            sort: sort,
            limit: limit
          });
        } catch (error) {
          e = error;
          return console.log(e);
        }
      }
    });
  };
});
```

Response:
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["admin_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["admin_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["admin_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "admin_#{name}", (sort, filter, limit) ->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e


Prompt:
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["admin_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["admin_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else

Response:
id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["admin_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "admin_#{name}", (sort, filter, limit) ->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e


Response:
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}

    fields = get_field_names(collection.find().fetch())
    c = Collections.findOne {name}
    if c
      Collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}

    fields = get_field_names(collection.find().fetch())
    c = Collections.findOne {name}
    if c
      Collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true
```

Response:
var c, fields, save_collections;

collection.find().observe({
  added: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: 1
      },
      $addToSet: {
        fields: {
          $each: get_field_names([document])
        }
      }
    });
  },
  removed: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

fields = get_field_names(collection.find().fetch());

c = Collections.findOne({name});

if (c) {
  Collections.update(c._id, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("admin_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return true;
  }
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var c, fields, save_collections;

collection.find().observe({
  added: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: 1
      },
      $addToSet: {
        fields: {
          $each: get_field_names([document])
        }
      }
    });
  },
  removed: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

fields = get_field_names(collection.find().fetch());

c = Collections.findOne({name});

if (c) {
  Collections.update(c._id, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("admin_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return true;
  }
});
```

Response:
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}

    fields = get_field_names(collection.find().fetch())
    c = Collections.findOne {name}
    if c
      Collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true


Prompt:
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}

    fields = get_field_names(collection.find().fetch())
    c = Collections.findOne {name}
    if c
      Collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and

Response:
(col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true


Response:
setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e

        set_up_collection(name, collections[name])

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish "admin", ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Collections.find()

Meteor.publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e

        set_up_collection(name, collections[name])

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish "admin", ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Collections.find()

Meteor.publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)
```

Response:
var fn, mongo_driver;

({
  setupNewCollection: function(name) {
    var e, key, user, value;
    if (!this.userId) {
      return;
    }
    user = Meteor.users.findOne(this.userId);
    if (!(user != null ? user.profile.admin : void 0)) {
      return;
    }
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        console.log(e);
      }
      return set_up_collection(name, collections[name]);
    }
  }
});

fn = Meteor.bindEnvironment(save_collections, function(e) {
  return console.log(e);
});

// MongoInternals is the 'right' solution as of 0.6.5
mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;

mongo_driver.mongo.db.collections(fn);

// publish our own internal state
Meteor.publish("admin", function() {
  if (Meteor.users.findOne({
    _id: this.userId,
    'profile.admin': true
  })) {
    return Collections.find();
  }
});

Meteor.publish('adminUser', function() { // used by login page to see if admin has been created yet
  return Meteor.users.find({
    'profile.admin': true
  }, {
    fields: {
      'profile.admin': true
    }
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var fn, mongo_driver;

({
  setupNewCollection: function(name) {
    var e, key, user, value;
    if (!this.userId) {
      return;
    }
    user = Meteor.users.findOne(this.userId);
    if (!(user != null ? user.profile.admin : void 0)) {
      return;
    }
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        console.log(e);
      }
      return set_up_collection(name, collections[name]);
    }
  }
});

fn = Meteor.bindEnvironment(save_collections, function(e) {
  return console.log(e);
});

// MongoInternals is the 'right' solution as of 0.6.5
mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;

mongo_driver.mongo.db.collections(fn);

// publish our own internal state
Meteor.publish("admin", function() {
  if (Meteor.users.findOne({
    _id: this.userId,
    'profile.admin': true
  })) {
    return Collections.find();
  }
});

Meteor.publish('adminUser', function() { // used by login page to see if admin has been created yet
  return Meteor.users.find({
    'profile.admin': true
  }, {
    fields: {
      'profile.admin': true
    }
  });
});
```

Response:
setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e

        set_up_collection(name, collections[name])

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish "admin", ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Collections.find()

Meteor.publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e

        set_up_collection(name, collections[name])

Response:
fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish "admin", ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Collections.find()

Meteor.publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Response:
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["_houston_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["_houston_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["_houston_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "_houston_#{name}", (sort, filter, limit)->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["_houston_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["_houston_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["_houston_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "_houston_#{name}", (sort, filter, limit)->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e
```

Response:
var Dummy, collections, root;

root = typeof exports !== "undefined" && exports !== null ? exports : this;

Dummy = new Meteor.Collection("system.dummy"); // hack.

collections = {
  'users': Meteor.users
};

Meteor.startup(function() {
  var set_up_collection;
  return set_up_collection = function(name, collection) {
    var methods;
    methods = {};
    methods[`_houston_${name}_insert`] = function(doc) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      return collection.insert(doc);
    };
    methods[`_houston_${name}_update`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.update(id, update_dict);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.update(id, update_dict);
      }
    };
    methods[`_houston_${name}_delete`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.remove(id);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.remove(id);
      }
    };
    Meteor.methods(methods);
    return Meteor.publish(`_houston_${name}`, function(sort, filter, limit) {
      var e;
      if (Meteor.users.findOne({
        _id: this.userId,
        'profile.admin': true
      })) {
        try {
          return collection.find(filter, {
            sort: sort,
            limit: limit
          });
        } catch (error) {
          e = error;
          return console.log(e);
        }
      }
    });
  };
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var Dummy, collections, root;

root = typeof exports !== "undefined" && exports !== null ? exports : this;

Dummy = new Meteor.Collection("system.dummy"); // hack.

collections = {
  'users': Meteor.users
};

Meteor.startup(function() {
  var set_up_collection;
  return set_up_collection = function(name, collection) {
    var methods;
    methods = {};
    methods[`_houston_${name}_insert`] = function(doc) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      return collection.insert(doc);
    };
    methods[`_houston_${name}_update`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.update(id, update_dict);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.update(id, update_dict);
      }
    };
    methods[`_houston_${name}_delete`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.remove(id);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.remove(id);
      }
    };
    Meteor.methods(methods);
    return Meteor.publish(`_houston_${name}`, function(sort, filter, limit) {
      var e;
      if (Meteor.users.findOne({
        _id: this.userId,
        'profile.admin': true
      })) {
        try {
          return collection.find(filter, {
            sort: sort,
            limit: limit
          });
        } catch (error) {
          e = error;
          return console.log(e);
        }
      }
    });
  };
});
```

Response:
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["_houston_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["_houston_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["_houston_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "_houston_#{name}", (sort, filter, limit)->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e


Prompt:
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["_houston_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["_houston_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else

Response:
id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["_houston_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "_houston_#{name}", (sort, filter, limit)->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e


Response:
collection.find().observe
      added: (document) ->
        Houston._collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}
    fields = Houston._get_field_names(collection.find().fetch())
    if Houston._collections.findOne {name}
      Houston._collections.update {name}, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return True

    _houston_setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
collection.find().observe
      added: (document) ->
        Houston._collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}
    fields = Houston._get_field_names(collection.find().fetch())
    if Houston._collections.findOne {name}
      Houston._collections.update {name}, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return True

    _houston_setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e
```

Response:
var fields, save_collections;

collection.find().observe({
  added: function(document) {
    return Houston._collections.update({name}, {
      $inc: {
        count: 1
      },
      $addToSet: {
        fields: Houston._get_field_names([document])
      }
    });
  },
  removed: function(document) {
    return Houston._collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

fields = Houston._get_field_names(collection.find().fetch());

if (Houston._collections.findOne({name})) {
  Houston._collections.update({name}, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Houston._collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("houston_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  _houston_make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return True;
  },
  _houston_setupNewCollection: function(name) {
    var e, key, user, value;
    if (!this.userId) {
      return;
    }
    user = Meteor.users.findOne(this.userId);
    if (!(user != null ? user.profile.admin : void 0)) {
      return;
    }
    if (!(name in collections)) {
      try {
        return collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        return console.log(e);
      }
    }
  }
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var fields, save_collections;

collection.find().observe({
  added: function(document) {
    return Houston._collections.update({name}, {
      $inc: {
        count: 1
      },
      $addToSet: {
        fields: Houston._get_field_names([document])
      }
    });
  },
  removed: function(document) {
    return Houston._collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

fields = Houston._get_field_names(collection.find().fetch());

if (Houston._collections.findOne({name})) {
  Houston._collections.update({name}, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Houston._collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("houston_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  _houston_make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return True;
  },
  _houston_setupNewCollection: function(name) {
    var e, key, user, value;
    if (!this.userId) {
      return;
    }
    user = Meteor.users.findOne(this.userId);
    if (!(user != null ? user.profile.admin : void 0)) {
      return;
    }
    if (!(name in collections)) {
      try {
        return collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        return console.log(e);
      }
    }
  }
});
```

Response:
collection.find().observe
      added: (document) ->
        Houston._collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}
    fields = Houston._get_field_names(collection.find().fetch())
    if Houston._collections.findOne {name}
      Houston._collections.update {name}, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return True

    _houston_setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e


Prompt:
collection.find().observe
      added: (document) ->
        Houston._collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}
    fields = Houston._get_field_names(collection.find().fetch())
    if Houston._collections.findOne {name}
      Houston._collections.update {name}, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root

Response:
if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return True

    _houston_setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e


Response:
set_up_collection(name, collections[name])

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.find()

Meteor.publish '_houston_adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
set_up_collection(name, collections[name])

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

Response:
# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.find()

Meteor.publish '_houston_adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Response:
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}

    fields = get_field_names(collection.find().fetch())
    c = Collections.findOne {name}
    if c
      Collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}

    fields = get_field_names(collection.find().fetch())
    c = Collections.findOne {name}
    if c
      Collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true
```

Response:
var c, fields, save_collections;

collection.find().observe({
  added: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: 1
      },
      $addToSet: {
        fields: get_field_names([document])
      }
    });
  },
  removed: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

fields = get_field_names(collection.find().fetch());

c = Collections.findOne({name});

if (c) {
  Collections.update(c._id, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("admin_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return true;
  }
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var c, fields, save_collections;

collection.find().observe({
  added: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: 1
      },
      $addToSet: {
        fields: get_field_names([document])
      }
    });
  },
  removed: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

fields = get_field_names(collection.find().fetch());

c = Collections.findOne({name});

if (c) {
  Collections.update(c._id, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("admin_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return true;
  }
});
```

Response:
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}

    fields = get_field_names(collection.find().fetch())
    c = Collections.findOne {name}
    if c
      Collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true


Prompt:
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}

    fields = get_field_names(collection.find().fetch())
    c = Collections.findOne {name}
    if c
      Collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and

Response:
(col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true


Response:
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}
    fields = get_field_names(collection.find().fetch())
    if Collections.findOne {name}
      Collections.update {name}, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true

    setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}
    fields = get_field_names(collection.find().fetch())
    if Collections.findOne {name}
      Collections.update {name}, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true

    setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e
```

Response:
var fields, save_collections;

collection.find().observe({
  added: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: 1
      },
      $addToSet: {
        fields: get_field_names([document])
      }
    });
  },
  removed: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

fields = get_field_names(collection.find().fetch());

if (Collections.findOne({name})) {
  Collections.update({name}, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("admin_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return true;
  },
  setupNewCollection: function(name) {
    var e, key, user, value;
    if (!this.userId) {
      return;
    }
    user = Meteor.users.findOne(this.userId);
    if (!(user != null ? user.profile.admin : void 0)) {
      return;
    }
    if (!(name in collections)) {
      try {
        return collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        return console.log(e);
      }
    }
  }
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var fields, save_collections;

collection.find().observe({
  added: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: 1
      },
      $addToSet: {
        fields: get_field_names([document])
      }
    });
  },
  removed: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

fields = get_field_names(collection.find().fetch());

if (Collections.findOne({name})) {
  Collections.update({name}, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("admin_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return true;
  },
  setupNewCollection: function(name) {
    var e, key, user, value;
    if (!this.userId) {
      return;
    }
    user = Meteor.users.findOne(this.userId);
    if (!(user != null ? user.profile.admin : void 0)) {
      return;
    }
    if (!(name in collections)) {
      try {
        return collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        return console.log(e);
      }
    }
  }
});
```

Response:
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}
    fields = get_field_names(collection.find().fetch())
    if Collections.findOne {name}
      Collections.update {name}, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true

    setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e


Prompt:
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}
    fields = get_field_names(collection.find().fetch())
    if Collections.findOne {name}
      Collections.update {name}, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root

Response:
if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true

    setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e


Response:
set_up_collection(name, collections[name])

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish "admin", ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Collections.find()

Meteor.publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
set_up_collection(name, collections[name])

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

Response:
# publish our own internal state
Meteor.publish "admin", ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Collections.find()

Meteor.publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Response:
publish_to_admin = (name, publish_func) ->
  Meteor.publish name, ->
    if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
      publish_func()

# publish our own internal state

publish_to_admin "admin", -> Collections.find()

Meteor.publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
publish_to_admin = (name, publish_func) ->
  Meteor.publish name, ->
    if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
      publish_func()

# publish our own internal state

publish_to_admin "admin", -> Collections.find()

Meteor.publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)
```

Response:
var publish_to_admin;

publish_to_admin = function(name, publish_func) {
  return Meteor.publish(name, function() {
    if (Meteor.users.findOne({
      _id: this.userId,
      'profile.admin': true
    })) {
      return publish_func();
    }
  });
};

// publish our own internal state
publish_to_admin("admin", function() {
  return Collections.find();
});

Meteor.publish('adminUser', function() { // used by login page to see if admin has been created yet
  return Meteor.users.find({
    'profile.admin': true
  }, {
    fields: {
      'profile.admin': true
    }
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var publish_to_admin;

publish_to_admin = function(name, publish_func) {
  return Meteor.publish(name, function() {
    if (Meteor.users.findOne({
      _id: this.userId,
      'profile.admin': true
    })) {
      return publish_func();
    }
  });
};

// publish our own internal state
publish_to_admin("admin", function() {
  return Collections.find();
});

Meteor.publish('adminUser', function() { // used by login page to see if admin has been created yet
  return Meteor.users.find({
    'profile.admin': true
  }, {
    fields: {
      'profile.admin': true
    }
  });
});
```

Response:
publish_to_admin = (name, publish_func) ->
  Meteor.publish name, ->
    if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
      publish_func()

# publish our own internal state

publish_to_admin "admin", -> Collections.find()

Meteor.publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
publish_to_admin = (name, publish_func) ->
  Meteor.publish name, ->
    if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
      publish_func()

Response:
# publish our own internal state

publish_to_admin "admin", -> Collections.find()

Meteor.publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Response:
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["admin_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["admin_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["admin_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "admin_#{name}", (sort, filter, limit)->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["admin_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["admin_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["admin_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "admin_#{name}", (sort, filter, limit)->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e
```

Response:
var Dummy, collections, root;

root = typeof exports !== "undefined" && exports !== null ? exports : this;

Dummy = new Meteor.Collection("system.dummy"); // hack.

collections = {
  'users': Meteor.users
};

Meteor.startup(function() {
  var set_up_collection;
  return set_up_collection = function(name, collection) {
    var methods;
    methods = {};
    methods[`admin_${name}_insert`] = function(doc) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      return collection.insert(doc);
    };
    methods[`admin_${name}_update`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.update(id, update_dict);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.update(id, update_dict);
      }
    };
    methods[`admin_${name}_delete`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.remove(id);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.remove(id);
      }
    };
    Meteor.methods(methods);
    return Meteor.publish(`admin_${name}`, function(sort, filter, limit) {
      var e;
      if (Meteor.users.findOne({
        _id: this.userId,
        'profile.admin': true
      })) {
        try {
          return collection.find(filter, {
            sort: sort,
            limit: limit
          });
        } catch (error) {
          e = error;
          return console.log(e);
        }
      }
    });
  };
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var Dummy, collections, root;

root = typeof exports !== "undefined" && exports !== null ? exports : this;

Dummy = new Meteor.Collection("system.dummy"); // hack.

collections = {
  'users': Meteor.users
};

Meteor.startup(function() {
  var set_up_collection;
  return set_up_collection = function(name, collection) {
    var methods;
    methods = {};
    methods[`admin_${name}_insert`] = function(doc) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      return collection.insert(doc);
    };
    methods[`admin_${name}_update`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.update(id, update_dict);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.update(id, update_dict);
      }
    };
    methods[`admin_${name}_delete`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.remove(id);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.remove(id);
      }
    };
    Meteor.methods(methods);
    return Meteor.publish(`admin_${name}`, function(sort, filter, limit) {
      var e;
      if (Meteor.users.findOne({
        _id: this.userId,
        'profile.admin': true
      })) {
        try {
          return collection.find(filter, {
            sort: sort,
            limit: limit
          });
        } catch (error) {
          e = error;
          return console.log(e);
        }
      }
    });
  };
});
```

Response:
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["admin_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["admin_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["admin_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "admin_#{name}", (sort, filter, limit)->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e


Prompt:
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["admin_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["admin_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else

Response:
id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["admin_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "admin_#{name}", (sort, filter, limit)->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e


Response:
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}
    fields = get_field_names(collection.find().fetch())
    if Collections.findOne {name}
      Collections.update {name}, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return True

    setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
collection.find().observe
      added: (document) ->
        Collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: get_field_names([document])
      removed: (document) -> Collections.update {name}, {$inc: {count: -1}}
    fields = get_field_names(collection.find().fetch())
    if Collections.findOne {name}
      Collections.update {name}, {$set: count: collection.find().count(), fields: fields}
    else
      Collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack
  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "admin_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e

        set_up_collection(name, collections[name])

  Meteor.methods
    make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return True

    setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e
```

Response:
var fields, save_collections;

collection.find().observe({
  added: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: 1
      },
      $addToSet: {
        fields: get_field_names([document])
      }
    });
  },
  removed: function(document) {
    return Collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

fields = get_field_names(collection.find().fetch());

if (Collections.findOne({name})) {
  Collections.update({name}, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("admin_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        console.log(e);
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return True;
  },
  setupNewCollection: function(name) {
    var e, key, user, value;
    if (!this.userId) {
      return;
    }
    user = Meteor.users.findOne(this.userId);
    if (!(user != null ? user.profile.admin : void 0)) {
      return;
    }
    if (!(name in collections)) {
      try {
        return collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        return console.log(e);
      }
    }
  }
});