Response:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  Houston._setup_collection_methods(collection)

  Houston._publish name, (sort, filter, limit, unknown_arg) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    check unknown_arg, Match.Any
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

  collection.find().observe
    _suppress_initial: true  # fixes houston for large initial datasets
    added: (document) ->
      Houston._collections.collections.update {name},
        $inc: {count: 1},
        $addToSet: fields: $each: Houston._get_fields([document])
    removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

  fields = Houston._get_fields_from_collection(collection)
  c = Houston._collections.collections.findOne {name}
  count = collection.find().count()
  if c
    Houston._collections.collections.update c._id, {$set: {count, fields}}
  else
    Houston._collections.collections.insert {name, count, fields}
  ADDED_COLLECTIONS[name] = collection


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  Houston._setup_collection_methods(collection)

  Houston._publish name, (sort, filter, limit, unknown_arg) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    check unknown_arg, Match.Any
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

  collection.find().observe
    _suppress_initial: true  # fixes houston for large initial datasets
    added: (document) ->
      Houston._collections.collections.update {name},
        $inc: {count: 1},
        $addToSet: fields: $each: Houston._get_fields([document])
    removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

  fields = Houston._get_fields_from_collection(collection)
  c = Houston._collections.collections.findOne {name}
  count = collection.find().count()
  if c
    Houston._collections.collections.update c._id, {$set: {count, fields}}
  else
    Houston._collections.collections.insert {name, count, fields}
  ADDED_COLLECTIONS[name] = collection
```

Response:
Houston._setup_collection = function(collection) {
  var c, count, fields;
  if (collection._name in ADDED_COLLECTIONS) {
    return;
  }
  Houston._setup_collection_methods(collection);
  Houston._publish(name, function(sort, filter, limit, unknown_arg) {
    var e;
    check(sort, Match.Optional(Object));
    check(filter, Match.Optional(Object));
    check(limit, Match.Optional(Number));
    check(unknown_arg, Match.Any);
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    try {
      return collection.find(filter, {
        sort: sort,
        limit: limit
      });
    } catch (error) {
      e = error;
      return console.log(e);
    }
  });
  collection.find().observe({
    _suppress_initial: true, // fixes houston for large initial datasets
    added: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: 1
        },
        $addToSet: {
          fields: {
            $each: Houston._get_fields([document])
          }
        }
      });
    },
    removed: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: -1
        }
      });
    }
  });
  fields = Houston._get_fields_from_collection(collection);
  c = Houston._collections.collections.findOne({name});
  count = collection.find().count();
  if (c) {
    Houston._collections.collections.update(c._id, {
      $set: {count, fields}
    });
  } else {
    Houston._collections.collections.insert({name, count, fields});
  }
  return ADDED_COLLECTIONS[name] = collection;
};


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
Houston._setup_collection = function(collection) {
  var c, count, fields;
  if (collection._name in ADDED_COLLECTIONS) {
    return;
  }
  Houston._setup_collection_methods(collection);
  Houston._publish(name, function(sort, filter, limit, unknown_arg) {
    var e;
    check(sort, Match.Optional(Object));
    check(filter, Match.Optional(Object));
    check(limit, Match.Optional(Number));
    check(unknown_arg, Match.Any);
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    try {
      return collection.find(filter, {
        sort: sort,
        limit: limit
      });
    } catch (error) {
      e = error;
      return console.log(e);
    }
  });
  collection.find().observe({
    _suppress_initial: true, // fixes houston for large initial datasets
    added: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: 1
        },
        $addToSet: {
          fields: {
            $each: Houston._get_fields([document])
          }
        }
      });
    },
    removed: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: -1
        }
      });
    }
  });
  fields = Houston._get_fields_from_collection(collection);
  c = Houston._collections.collections.findOne({name});
  count = collection.find().count();
  if (c) {
    Houston._collections.collections.update(c._id, {
      $set: {count, fields}
    });
  } else {
    Houston._collections.collections.insert({name, count, fields});
  }
  return ADDED_COLLECTIONS[name] = collection;
};
```

Response:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  Houston._setup_collection_methods(collection)

  Houston._publish name, (sort, filter, limit, unknown_arg) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    check unknown_arg, Match.Any
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

  collection.find().observe
    _suppress_initial: true  # fixes houston for large initial datasets
    added: (document) ->
      Houston._collections.collections.update {name},
        $inc: {count: 1},
        $addToSet: fields: $each: Houston._get_fields([document])
    removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

  fields = Houston._get_fields_from_collection(collection)
  c = Houston._collections.collections.findOne {name}
  count = collection.find().count()
  if c
    Houston._collections.collections.update c._id, {$set: {count, fields}}
  else
    Houston._collections.collections.insert {name, count, fields}
  ADDED_COLLECTIONS[name] = collection


Prompt:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  Houston._setup_collection_methods(collection)

  Houston._publish name, (sort, filter, limit, unknown_arg) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    check unknown_arg, Match.Any
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

Response:
collection.find().observe
    _suppress_initial: true  # fixes houston for large initial datasets
    added: (document) ->
      Houston._collections.collections.update {name},
        $inc: {count: 1},
        $addToSet: fields: $each: Houston._get_fields([document])
    removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

  fields = Houston._get_fields_from_collection(collection)
  c = Houston._collections.collections.findOne {name}
  count = collection.find().count()
  if c
    Houston._collections.collections.update c._id, {$set: {count, fields}}
  else
    Houston._collections.collections.insert {name, count, fields}
  ADDED_COLLECTIONS[name] = collection


Response:
sync_collections = ->
  Dummy.findOne()  # hack. TODO: verify this is still necessary

  _sync_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 ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS
        new_collection = null
        try
          new_collection = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value?._name # TODO here - typecheck also?
              new_collection = value

        if new_collection?  # found it!
          Houston._setup_collection(new_collection)
        else
          console.log """
Houston: couldn't find access to the #{name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or
(2) add the collection manually via Houston.add_collection
"""

  bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->
    console.log "Failed while syncing collections for reason: #{e}"

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

Meteor.methods
  _houston_make_admin: (user_id) ->
    check user_id, String
    # limit one admin
    return if Houston._admins.findOne {'user_id': $exists: true}
    Houston._admins.insert {user_id}
    sync_collections() # reloads collections in case of new app
    return true

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# TODO address inherent security issue


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
sync_collections = ->
  Dummy.findOne()  # hack. TODO: verify this is still necessary

  _sync_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 ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS
        new_collection = null
        try
          new_collection = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value?._name # TODO here - typecheck also?
              new_collection = value

        if new_collection?  # found it!
          Houston._setup_collection(new_collection)
        else
          console.log """
Houston: couldn't find access to the #{name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or
(2) add the collection manually via Houston.add_collection
"""

  bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->
    console.log "Failed while syncing collections for reason: #{e}"

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

Meteor.methods
  _houston_make_admin: (user_id) ->
    check user_id, String
    # limit one admin
    return if Houston._admins.findOne {'user_id': $exists: true}
    Houston._admins.insert {user_id}
    sync_collections() # reloads collections in case of new app
    return true

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# TODO address inherent security issue
```

Response:
var sync_collections;

sync_collections = function() {
  var _sync_collections, bound_sync_collections, mongo_driver;
  Dummy.findOne(); // hack. TODO: verify this is still necessary
  _sync_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, new_collection, value;
      if (!(name in ADDED_COLLECTIONS || name in Houston._HIDDEN_COLLECTIONS)) {
        new_collection = null;
        try {
          new_collection = new Meteor.Collection(name);
        } catch (error) {
          e = error;
          for (key in root) {
            value = root[key];
            if (name === (value != null ? value._name : void 0)) { // TODO here - typecheck also?
              new_collection = value;
            }
          }
        }
        if (new_collection != null) {
          return Houston._setup_collection(new_collection);
        } else {
          return console.log(`Houston: couldn't find access to the ${name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or
(2) add the collection manually via Houston.add_collection`); // found it!
        }
      }
    });
  };
  bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {
    return console.log(`Failed while syncing collections for reason: ${e}`);
  });
  // MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;
  return mongo_driver.mongo.db.collections(bound_sync_collections);
};

Meteor.methods({
  _houston_make_admin: function(user_id) {
    check(user_id, String);
    // limit one admin
    if (Houston._admins.findOne({
      'user_id': {
        $exists: true
      }
    })) {
      return;
    }
    Houston._admins.insert({user_id});
    sync_collections(); // reloads collections in case of new app
    return true;
  }
});

// publish our analysis of the app's collections
Houston._publish('collections', function() {
  if (!Houston._user_is_admin(this.userId)) {
    return;
  }
  return Houston._collections.collections.find();
});

// TODO address inherent security issue


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

sync_collections = function() {
  var _sync_collections, bound_sync_collections, mongo_driver;
  Dummy.findOne(); // hack. TODO: verify this is still necessary
  _sync_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, new_collection, value;
      if (!(name in ADDED_COLLECTIONS || name in Houston._HIDDEN_COLLECTIONS)) {
        new_collection = null;
        try {
          new_collection = new Meteor.Collection(name);
        } catch (error) {
          e = error;
          for (key in root) {
            value = root[key];
            if (name === (value != null ? value._name : void 0)) { // TODO here - typecheck also?
              new_collection = value;
            }
          }
        }
        if (new_collection != null) {
          return Houston._setup_collection(new_collection);
        } else {
          return console.log(`Houston: couldn't find access to the ${name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or
(2) add the collection manually via Houston.add_collection`); // found it!
        }
      }
    });
  };
  bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {
    return console.log(`Failed while syncing collections for reason: ${e}`);
  });
  // MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;
  return mongo_driver.mongo.db.collections(bound_sync_collections);
};

Meteor.methods({
  _houston_make_admin: function(user_id) {
    check(user_id, String);
    // limit one admin
    if (Houston._admins.findOne({
      'user_id': {
        $exists: true
      }
    })) {
      return;
    }
    Houston._admins.insert({user_id});
    sync_collections(); // reloads collections in case of new app
    return true;
  }
});

// publish our analysis of the app's collections
Houston._publish('collections', function() {
  if (!Houston._user_is_admin(this.userId)) {
    return;
  }
  return Houston._collections.collections.find();
});

// TODO address inherent security issue
```

Response:
sync_collections = ->
  Dummy.findOne()  # hack. TODO: verify this is still necessary

  _sync_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 ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS
        new_collection = null
        try
          new_collection = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value?._name # TODO here - typecheck also?
              new_collection = value

        if new_collection?  # found it!
          Houston._setup_collection(new_collection)
        else
          console.log """
Houston: couldn't find access to the #{name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or
(2) add the collection manually via Houston.add_collection
"""

  bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->
    console.log "Failed while syncing collections for reason: #{e}"

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

Meteor.methods
  _houston_make_admin: (user_id) ->
    check user_id, String
    # limit one admin
    return if Houston._admins.findOne {'user_id': $exists: true}
    Houston._admins.insert {user_id}
    sync_collections() # reloads collections in case of new app
    return true

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# TODO address inherent security issue


Prompt:
sync_collections = ->
  Dummy.findOne()  # hack. TODO: verify this is still necessary

  _sync_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 ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS
        new_collection = null
        try
          new_collection = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value?._name # TODO here - typecheck also?
              new_collection = value

        if new_collection?  # found it!
          Houston._setup_collection(new_collection)
        else
          console.log """
Houston: couldn't find access to the #{name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or

Response:
(2) add the collection manually via Houston.add_collection
"""

  bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->
    console.log "Failed while syncing collections for reason: #{e}"

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

Meteor.methods
  _houston_make_admin: (user_id) ->
    check user_id, String
    # limit one admin
    return if Houston._admins.findOne {'user_id': $exists: true}
    Houston._admins.insert {user_id}
    sync_collections() # reloads collections in case of new app
    return true

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# TODO address inherent security issue


Response:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    check doc, Object
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    check id, Match.Any
    check update_dict, Object
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id) ->
    check id, Match.Any
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)
    else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

  Meteor.methods methods

  Houston._publish name, (sort, filter, limit, unknown_arg) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    check unknown_arg, Match.Any
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

  collection.find().observe
    added: (document) ->
      Houston._collections.collections.update {name},
        $inc: {count: 1},
        $addToSet: fields: $each: Houston._get_fields([document])
    removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

  fields = Houston._get_fields(collection.find().fetch())


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    check doc, Object
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    check id, Match.Any
    check update_dict, Object
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id) ->
    check id, Match.Any
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)
    else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

  Meteor.methods methods

  Houston._publish name, (sort, filter, limit, unknown_arg) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    check unknown_arg, Match.Any
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

  collection.find().observe
    added: (document) ->
      Houston._collections.collections.update {name},
        $inc: {count: 1},
        $addToSet: fields: $each: Houston._get_fields([document])
    removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

  fields = Houston._get_fields(collection.find().fetch())
```

Response:
Houston._setup_collection = function(collection) {
  var fields, methods, name;
  if (collection._name in ADDED_COLLECTIONS) {
    return;
  }
  name = collection._name;
  methods = {};
  methods[Houston._houstonize(`${name}_insert`)] = function(doc) {
    check(doc, Object);
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    return collection.insert(doc);
  };
  methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {
    check(id, Match.Any);
    check(update_dict, Object);
    if (!Houston._user_is_admin(this.userId)) {
      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._houstonize(`${name}_delete`)] = function(id) {
    check(id, Match.Any);
    if (!Houston._user_is_admin(this.userId)) {
      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);
  Houston._publish(name, function(sort, filter, limit, unknown_arg) {
    var e;
    check(sort, Match.Optional(Object));
    check(filter, Match.Optional(Object));
    check(limit, Match.Optional(Number));
    check(unknown_arg, Match.Any);
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    try {
      return collection.find(filter, {
        sort: sort,
        limit: limit
      });
    } catch (error) {
      e = error;
      return console.log(e);
    }
  });
  collection.find().observe({
    added: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: 1
        },
        $addToSet: {
          fields: {
            $each: Houston._get_fields([document])
          }
        }
      });
    },
    removed: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: -1
        }
      });
    }
  });
  return fields = Houston._get_fields(collection.find().fetch());
};


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
Houston._setup_collection = function(collection) {
  var fields, methods, name;
  if (collection._name in ADDED_COLLECTIONS) {
    return;
  }
  name = collection._name;
  methods = {};
  methods[Houston._houstonize(`${name}_insert`)] = function(doc) {
    check(doc, Object);
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    return collection.insert(doc);
  };
  methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {
    check(id, Match.Any);
    check(update_dict, Object);
    if (!Houston._user_is_admin(this.userId)) {
      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._houstonize(`${name}_delete`)] = function(id) {
    check(id, Match.Any);
    if (!Houston._user_is_admin(this.userId)) {
      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);
  Houston._publish(name, function(sort, filter, limit, unknown_arg) {
    var e;
    check(sort, Match.Optional(Object));
    check(filter, Match.Optional(Object));
    check(limit, Match.Optional(Number));
    check(unknown_arg, Match.Any);
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    try {
      return collection.find(filter, {
        sort: sort,
        limit: limit
      });
    } catch (error) {
      e = error;
      return console.log(e);
    }
  });
  collection.find().observe({
    added: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: 1
        },
        $addToSet: {
          fields: {
            $each: Houston._get_fields([document])
          }
        }
      });
    },
    removed: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: -1
        }
      });
    }
  });
  return fields = Houston._get_fields(collection.find().fetch());
};
```

Response:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    check doc, Object
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    check id, Match.Any
    check update_dict, Object
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id) ->
    check id, Match.Any
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)
    else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

  Meteor.methods methods

  Houston._publish name, (sort, filter, limit, unknown_arg) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    check unknown_arg, Match.Any
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

  collection.find().observe
    added: (document) ->
      Houston._collections.collections.update {name},
        $inc: {count: 1},
        $addToSet: fields: $each: Houston._get_fields([document])
    removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

  fields = Houston._get_fields(collection.find().fetch())


Prompt:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    check doc, Object
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    check id, Match.Any
    check update_dict, Object
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id) ->
    check id, Match.Any
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)

Response:
else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

  Meteor.methods methods

  Houston._publish name, (sort, filter, limit, unknown_arg) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    check unknown_arg, Match.Any
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

  collection.find().observe
    added: (document) ->
      Houston._collections.collections.update {name},
        $inc: {count: 1},
        $addToSet: fields: $each: Houston._get_fields([document])
    removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

  fields = Houston._get_fields(collection.find().fetch())


Response:
c = Houston._collections.collections.findOne {name}
  if c
    Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
  else
    Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}
  ADDED_COLLECTIONS[name] = collection


Prompt:
c = Houston._collections.collections.findOne {name}
  if c
    Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}

Response:
else
    Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}
  ADDED_COLLECTIONS[name] = collection


Response:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    check doc, Object
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    check id, Match.Any
    check update_dict, Object
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id) ->
    check id, Match.Any
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)
    else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

  Meteor.methods methods

  Houston._publish name, (sort, filter, limit, unknown_arg) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    check unknown_arg, Match.Any
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

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

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


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    check doc, Object
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    check id, Match.Any
    check update_dict, Object
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id) ->
    check id, Match.Any
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)
    else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

  Meteor.methods methods

  Houston._publish name, (sort, filter, limit, unknown_arg) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    check unknown_arg, Match.Any
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

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

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

Response:
Houston._setup_collection = function(collection) {
  var fields, methods, name;
  if (collection._name in ADDED_COLLECTIONS) {
    return;
  }
  name = collection._name;
  methods = {};
  methods[Houston._houstonize(`${name}_insert`)] = function(doc) {
    check(doc, Object);
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    return collection.insert(doc);
  };
  methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {
    check(id, Match.Any);
    check(update_dict, Object);
    if (!Houston._user_is_admin(this.userId)) {
      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._houstonize(`${name}_delete`)] = function(id) {
    check(id, Match.Any);
    if (!Houston._user_is_admin(this.userId)) {
      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);
  Houston._publish(name, function(sort, filter, limit, unknown_arg) {
    var e;
    check(sort, Match.Optional(Object));
    check(filter, Match.Optional(Object));
    check(limit, Match.Optional(Number));
    check(unknown_arg, Match.Any);
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    try {
      return collection.find(filter, {
        sort: sort,
        limit: limit
      });
    } catch (error) {
      e = error;
      return console.log(e);
    }
  });
  collection.find().observe({
    added: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: 1
        },
        $addToSet: {
          fields: {
            $each: Houston._get_field_names([document])
          }
        }
      });
    },
    removed: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: -1
        }
      });
    }
  });
  return fields = Houston._get_field_names(collection.find().fetch());
};


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
Houston._setup_collection = function(collection) {
  var fields, methods, name;
  if (collection._name in ADDED_COLLECTIONS) {
    return;
  }
  name = collection._name;
  methods = {};
  methods[Houston._houstonize(`${name}_insert`)] = function(doc) {
    check(doc, Object);
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    return collection.insert(doc);
  };
  methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {
    check(id, Match.Any);
    check(update_dict, Object);
    if (!Houston._user_is_admin(this.userId)) {
      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._houstonize(`${name}_delete`)] = function(id) {
    check(id, Match.Any);
    if (!Houston._user_is_admin(this.userId)) {
      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);
  Houston._publish(name, function(sort, filter, limit, unknown_arg) {
    var e;
    check(sort, Match.Optional(Object));
    check(filter, Match.Optional(Object));
    check(limit, Match.Optional(Number));
    check(unknown_arg, Match.Any);
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    try {
      return collection.find(filter, {
        sort: sort,
        limit: limit
      });
    } catch (error) {
      e = error;
      return console.log(e);
    }
  });
  collection.find().observe({
    added: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: 1
        },
        $addToSet: {
          fields: {
            $each: Houston._get_field_names([document])
          }
        }
      });
    },
    removed: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: -1
        }
      });
    }
  });
  return fields = Houston._get_field_names(collection.find().fetch());
};
```

Response:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    check doc, Object
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    check id, Match.Any
    check update_dict, Object
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id) ->
    check id, Match.Any
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)
    else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

  Meteor.methods methods

  Houston._publish name, (sort, filter, limit, unknown_arg) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    check unknown_arg, Match.Any
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

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

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


Prompt:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    check doc, Object
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    check id, Match.Any
    check update_dict, Object
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id) ->
    check id, Match.Any
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)

Response:
else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

  Meteor.methods methods

  Houston._publish name, (sort, filter, limit, unknown_arg) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    check unknown_arg, Match.Any
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

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

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


Response:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)
    else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

  Meteor.methods methods

  Houston._publish name, (sort, filter, limit) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

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

  fields = Houston._get_field_names(collection.find().fetch())
  c = Houston._collections.collections.findOne {name}
  if c
    Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
  else
    Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)
    else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

  Meteor.methods methods

  Houston._publish name, (sort, filter, limit) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

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

  fields = Houston._get_field_names(collection.find().fetch())
  c = Houston._collections.collections.findOne {name}
  if c
    Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
  else
    Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}
```

Response:
Houston._setup_collection = function(collection) {
  var c, fields, methods, name;
  if (collection._name in ADDED_COLLECTIONS) {
    return;
  }
  name = collection._name;
  methods = {};
  methods[Houston._houstonize(`${name}_insert`)] = function(doc) {
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    return collection.insert(doc);
  };
  methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {
    if (!Houston._user_is_admin(this.userId)) {
      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._houstonize(`${name}_delete`)] = function(id, update_dict) {
    if (!Houston._user_is_admin(this.userId)) {
      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);
  Houston._publish(name, function(sort, filter, limit) {
    var e;
    check(sort, Match.Optional(Object));
    check(filter, Match.Optional(Object));
    check(limit, Match.Optional(Number));
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    try {
      return collection.find(filter, {
        sort: sort,
        limit: limit
      });
    } catch (error) {
      e = error;
      return console.log(e);
    }
  });
  collection.find().observe({
    added: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: 1
        },
        $addToSet: {
          fields: {
            $each: Houston._get_field_names([document])
          }
        }
      });
    },
    removed: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: -1
        }
      });
    }
  });
  fields = Houston._get_field_names(collection.find().fetch());
  c = Houston._collections.collections.findOne({name});
  if (c) {
    return Houston._collections.collections.update(c._id, {
      $set: {
        count: collection.find().count(),
        fields: fields
      }
    });
  } else {
    return Houston._collections.collections.insert({
      name,
      count: collection.find().count(),
      fields: fields
    });
  }
};


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
Houston._setup_collection = function(collection) {
  var c, fields, methods, name;
  if (collection._name in ADDED_COLLECTIONS) {
    return;
  }
  name = collection._name;
  methods = {};
  methods[Houston._houstonize(`${name}_insert`)] = function(doc) {
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    return collection.insert(doc);
  };
  methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {
    if (!Houston._user_is_admin(this.userId)) {
      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._houstonize(`${name}_delete`)] = function(id, update_dict) {
    if (!Houston._user_is_admin(this.userId)) {
      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);
  Houston._publish(name, function(sort, filter, limit) {
    var e;
    check(sort, Match.Optional(Object));
    check(filter, Match.Optional(Object));
    check(limit, Match.Optional(Number));
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    try {
      return collection.find(filter, {
        sort: sort,
        limit: limit
      });
    } catch (error) {
      e = error;
      return console.log(e);
    }
  });
  collection.find().observe({
    added: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: 1
        },
        $addToSet: {
          fields: {
            $each: Houston._get_field_names([document])
          }
        }
      });
    },
    removed: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: -1
        }
      });
    }
  });
  fields = Houston._get_field_names(collection.find().fetch());
  c = Houston._collections.collections.findOne({name});
  if (c) {
    return Houston._collections.collections.update(c._id, {
      $set: {
        count: collection.find().count(),
        fields: fields
      }
    });
  } else {
    return Houston._collections.collections.insert({
      name,
      count: collection.find().count(),
      fields: fields
    });
  }
};
```

Response:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)
    else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

  Meteor.methods methods

  Houston._publish name, (sort, filter, limit) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

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

  fields = Houston._get_field_names(collection.find().fetch())
  c = Houston._collections.collections.findOne {name}
  if c
    Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
  else
    Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}


Prompt:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)
    else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

Response:
Meteor.methods methods

  Houston._publish name, (sort, filter, limit) ->
    check sort, Match.Optional(Object)
    check filter, Match.Optional(Object)
    check limit, Match.Optional(Number)
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

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

  fields = Houston._get_field_names(collection.find().fetch())
  c = Houston._collections.collections.findOne {name}
  if c
    Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
  else
    Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}


Response:
sync_collections = ->
  Dummy.findOne()  # hack. TODO: verify this is still necessary

  _sync_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 ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS
        new_collection = null
        try
          new_collection = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value?._name # TODO here - typecheck also?
              new_collection = value

        if new_collection?  # found it!
          Houston._setup_collection(new_collection)
        else
          console.log """
Houston: couldn't find access to the #{name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or
(2) add the collection manually via Houston.add_collection
"""

  bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->
    console.log "Failed while syncing collections for reason: #{e}"

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

Meteor.methods
  _houston_make_admin: (user_id) ->
    check user_id, String
    # limit one admin
    return if Houston._admins.findOne {'user_id': $exists: true}
    Houston._admins.insert {user_id}
    sync_collections() # reloads collections in case of new app
    return true

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# TODO address inherent security issue


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
sync_collections = ->
  Dummy.findOne()  # hack. TODO: verify this is still necessary

  _sync_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 ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS
        new_collection = null
        try
          new_collection = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value?._name # TODO here - typecheck also?
              new_collection = value

        if new_collection?  # found it!
          Houston._setup_collection(new_collection)
        else
          console.log """
Houston: couldn't find access to the #{name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or
(2) add the collection manually via Houston.add_collection
"""

  bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->
    console.log "Failed while syncing collections for reason: #{e}"

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

Meteor.methods
  _houston_make_admin: (user_id) ->
    check user_id, String
    # limit one admin
    return if Houston._admins.findOne {'user_id': $exists: true}
    Houston._admins.insert {user_id}
    sync_collections() # reloads collections in case of new app
    return true

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# TODO address inherent security issue
```

Response:
var sync_collections;

sync_collections = function() {
  var _sync_collections, bound_sync_collections, mongo_driver;
  Dummy.findOne(); // hack. TODO: verify this is still necessary
  _sync_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, new_collection, value;
      if (!(name in ADDED_COLLECTIONS || name in HIDDEN_COLLECTIONS)) {
        new_collection = null;
        try {
          new_collection = new Meteor.Collection(name);
        } catch (error) {
          e = error;
          for (key in root) {
            value = root[key];
            if (name === (value != null ? value._name : void 0)) { // TODO here - typecheck also?
              new_collection = value;
            }
          }
        }
        if (new_collection != null) {
          return Houston._setup_collection(new_collection);
        } else {
          return console.log(`Houston: couldn't find access to the ${name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or
(2) add the collection manually via Houston.add_collection`); // found it!
        }
      }
    });
  };
  bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {
    return console.log(`Failed while syncing collections for reason: ${e}`);
  });
  // MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;
  return mongo_driver.mongo.db.collections(bound_sync_collections);
};

Meteor.methods({
  _houston_make_admin: function(user_id) {
    check(user_id, String);
    // limit one admin
    if (Houston._admins.findOne({
      'user_id': {
        $exists: true
      }
    })) {
      return;
    }
    Houston._admins.insert({user_id});
    sync_collections(); // reloads collections in case of new app
    return true;
  }
});

// publish our analysis of the app's collections
Houston._publish('collections', function() {
  if (!Houston._user_is_admin(this.userId)) {
    return;
  }
  return Houston._collections.collections.find();
});

// TODO address inherent security issue


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

sync_collections = function() {
  var _sync_collections, bound_sync_collections, mongo_driver;
  Dummy.findOne(); // hack. TODO: verify this is still necessary
  _sync_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, new_collection, value;
      if (!(name in ADDED_COLLECTIONS || name in HIDDEN_COLLECTIONS)) {
        new_collection = null;
        try {
          new_collection = new Meteor.Collection(name);
        } catch (error) {
          e = error;
          for (key in root) {
            value = root[key];
            if (name === (value != null ? value._name : void 0)) { // TODO here - typecheck also?
              new_collection = value;
            }
          }
        }
        if (new_collection != null) {
          return Houston._setup_collection(new_collection);
        } else {
          return console.log(`Houston: couldn't find access to the ${name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or
(2) add the collection manually via Houston.add_collection`); // found it!
        }
      }
    });
  };
  bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {
    return console.log(`Failed while syncing collections for reason: ${e}`);
  });
  // MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;
  return mongo_driver.mongo.db.collections(bound_sync_collections);
};

Meteor.methods({
  _houston_make_admin: function(user_id) {
    check(user_id, String);
    // limit one admin
    if (Houston._admins.findOne({
      'user_id': {
        $exists: true
      }
    })) {
      return;
    }
    Houston._admins.insert({user_id});
    sync_collections(); // reloads collections in case of new app
    return true;
  }
});

// publish our analysis of the app's collections
Houston._publish('collections', function() {
  if (!Houston._user_is_admin(this.userId)) {
    return;
  }
  return Houston._collections.collections.find();
});

// TODO address inherent security issue
```

Response:
sync_collections = ->
  Dummy.findOne()  # hack. TODO: verify this is still necessary

  _sync_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 ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS
        new_collection = null
        try
          new_collection = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value?._name # TODO here - typecheck also?
              new_collection = value

        if new_collection?  # found it!
          Houston._setup_collection(new_collection)
        else
          console.log """
Houston: couldn't find access to the #{name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or
(2) add the collection manually via Houston.add_collection
"""

  bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->
    console.log "Failed while syncing collections for reason: #{e}"

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

Meteor.methods
  _houston_make_admin: (user_id) ->
    check user_id, String
    # limit one admin
    return if Houston._admins.findOne {'user_id': $exists: true}
    Houston._admins.insert {user_id}
    sync_collections() # reloads collections in case of new app
    return true

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# TODO address inherent security issue


Prompt:
sync_collections = ->
  Dummy.findOne()  # hack. TODO: verify this is still necessary

  _sync_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 ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS
        new_collection = null
        try
          new_collection = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value?._name # TODO here - typecheck also?
              new_collection = value

        if new_collection?  # found it!
          Houston._setup_collection(new_collection)
        else
          console.log """
Houston: couldn't find access to the #{name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or

Response:
(2) add the collection manually via Houston.add_collection
"""

  bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->
    console.log "Failed while syncing collections for reason: #{e}"

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

Meteor.methods
  _houston_make_admin: (user_id) ->
    check user_id, String
    # limit one admin
    return if Houston._admins.findOne {'user_id': $exists: true}
    Houston._admins.insert {user_id}
    sync_collections() # reloads collections in case of new app
    return true

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# TODO address inherent security issue


Response:
sync_collections = ->
  Dummy.findOne()  # hack. TODO: verify this is still necessary

  _sync_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 ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS
        new_collection = null
        try
          new_collection = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name # TODO here - typecheck also?
              new_collection = value

        if new_collection?  # found it!
          Houston._setup_collection(new_collection)
        else
          console.log """
Houston: couldn't find access to the #{name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or
(2) add the collection manually via Houston.add_collection
"""

  bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->
    console.log "Failed while syncing collections for reason: #{e}"

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

Meteor.methods
  _houston_make_admin: (user_id) ->
    check userId, String
    # limit one admin
    return if Houston._admins.findOne {'user_id': $exists: true}
    Houston._admins.insert {user_id}
    sync_collections() # reloads collections in case of new app
    return true

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# TODO address inherent security issue


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
sync_collections = ->
  Dummy.findOne()  # hack. TODO: verify this is still necessary

  _sync_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 ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS
        new_collection = null
        try
          new_collection = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name # TODO here - typecheck also?
              new_collection = value

        if new_collection?  # found it!
          Houston._setup_collection(new_collection)
        else
          console.log """
Houston: couldn't find access to the #{name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or
(2) add the collection manually via Houston.add_collection
"""

  bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->
    console.log "Failed while syncing collections for reason: #{e}"

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

Meteor.methods
  _houston_make_admin: (user_id) ->
    check userId, String
    # limit one admin
    return if Houston._admins.findOne {'user_id': $exists: true}
    Houston._admins.insert {user_id}
    sync_collections() # reloads collections in case of new app
    return true

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# TODO address inherent security issue
```

Response:
var sync_collections;

sync_collections = function() {
  var _sync_collections, bound_sync_collections, mongo_driver;
  Dummy.findOne(); // hack. TODO: verify this is still necessary
  _sync_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, new_collection, value;
      if (!(name in ADDED_COLLECTIONS || name in HIDDEN_COLLECTIONS)) {
        new_collection = null;
        try {
          new_collection = new Meteor.Collection(name);
        } catch (error) {
          e = error;
          for (key in root) {
            value = root[key];
            if (name === value._name) { // TODO here - typecheck also?
              new_collection = value;
            }
          }
        }
        if (new_collection != null) {
          return Houston._setup_collection(new_collection);
        } else {
          return console.log(`Houston: couldn't find access to the ${name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or
(2) add the collection manually via Houston.add_collection`); // found it!
        }
      }
    });
  };
  bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {
    return console.log(`Failed while syncing collections for reason: ${e}`);
  });
  // MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;
  return mongo_driver.mongo.db.collections(bound_sync_collections);
};

Meteor.methods({
  _houston_make_admin: function(user_id) {
    check(userId, String);
    // limit one admin
    if (Houston._admins.findOne({
      'user_id': {
        $exists: true
      }
    })) {
      return;
    }
    Houston._admins.insert({user_id});
    sync_collections(); // reloads collections in case of new app
    return true;
  }
});

// publish our analysis of the app's collections
Houston._publish('collections', function() {
  if (!Houston._user_is_admin(this.userId)) {
    return;
  }
  return Houston._collections.collections.find();
});

// TODO address inherent security issue


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

sync_collections = function() {
  var _sync_collections, bound_sync_collections, mongo_driver;
  Dummy.findOne(); // hack. TODO: verify this is still necessary
  _sync_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, new_collection, value;
      if (!(name in ADDED_COLLECTIONS || name in HIDDEN_COLLECTIONS)) {
        new_collection = null;
        try {
          new_collection = new Meteor.Collection(name);
        } catch (error) {
          e = error;
          for (key in root) {
            value = root[key];
            if (name === value._name) { // TODO here - typecheck also?
              new_collection = value;
            }
          }
        }
        if (new_collection != null) {
          return Houston._setup_collection(new_collection);
        } else {
          return console.log(`Houston: couldn't find access to the ${name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or
(2) add the collection manually via Houston.add_collection`); // found it!
        }
      }
    });
  };
  bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {
    return console.log(`Failed while syncing collections for reason: ${e}`);
  });
  // MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;
  return mongo_driver.mongo.db.collections(bound_sync_collections);
};

Meteor.methods({
  _houston_make_admin: function(user_id) {
    check(userId, String);
    // limit one admin
    if (Houston._admins.findOne({
      'user_id': {
        $exists: true
      }
    })) {
      return;
    }
    Houston._admins.insert({user_id});
    sync_collections(); // reloads collections in case of new app
    return true;
  }
});

// publish our analysis of the app's collections
Houston._publish('collections', function() {
  if (!Houston._user_is_admin(this.userId)) {
    return;
  }
  return Houston._collections.collections.find();
});

// TODO address inherent security issue
```

Response:
sync_collections = ->
  Dummy.findOne()  # hack. TODO: verify this is still necessary

  _sync_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 ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS
        new_collection = null
        try
          new_collection = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name # TODO here - typecheck also?
              new_collection = value

        if new_collection?  # found it!
          Houston._setup_collection(new_collection)
        else
          console.log """
Houston: couldn't find access to the #{name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or
(2) add the collection manually via Houston.add_collection
"""

  bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->
    console.log "Failed while syncing collections for reason: #{e}"

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

Meteor.methods
  _houston_make_admin: (user_id) ->
    check userId, String
    # limit one admin
    return if Houston._admins.findOne {'user_id': $exists: true}
    Houston._admins.insert {user_id}
    sync_collections() # reloads collections in case of new app
    return true

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# TODO address inherent security issue


Prompt:
sync_collections = ->
  Dummy.findOne()  # hack. TODO: verify this is still necessary

  _sync_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 ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS
        new_collection = null
        try
          new_collection = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name # TODO here - typecheck also?
              new_collection = value

        if new_collection?  # found it!
          Houston._setup_collection(new_collection)
        else
          console.log """
Houston: couldn't find access to the #{name} collection.
If you'd like to access the collection from Houston, either
(1) make sure it is available as a global (top-level namespace) within the server or

Response:
(2) add the collection manually via Houston.add_collection
"""

  bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->
    console.log "Failed while syncing collections for reason: #{e}"

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

Meteor.methods
  _houston_make_admin: (user_id) ->
    check userId, String
    # limit one admin
    return if Houston._admins.findOne {'user_id': $exists: true}
    Houston._admins.insert {user_id}
    sync_collections() # reloads collections in case of new app
    return true

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# TODO address inherent security issue


Response:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)
    else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

  Meteor.methods methods

  Houston._publish name, (sort, filter, limit) ->
    check sort, Object
    check filter, Object
    check limit, Number
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

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

  fields = Houston._get_field_names(collection.find().fetch())
  c = Houston._collections.collections.findOne {name}
  if c
    Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
  else
    Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)
    else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

  Meteor.methods methods

  Houston._publish name, (sort, filter, limit) ->
    check sort, Object
    check filter, Object
    check limit, Number
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

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

  fields = Houston._get_field_names(collection.find().fetch())
  c = Houston._collections.collections.findOne {name}
  if c
    Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
  else
    Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}
```

Response:
Houston._setup_collection = function(collection) {
  var c, fields, methods, name;
  if (collection._name in ADDED_COLLECTIONS) {
    return;
  }
  name = collection._name;
  methods = {};
  methods[Houston._houstonize(`${name}_insert`)] = function(doc) {
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    return collection.insert(doc);
  };
  methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {
    if (!Houston._user_is_admin(this.userId)) {
      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._houstonize(`${name}_delete`)] = function(id, update_dict) {
    if (!Houston._user_is_admin(this.userId)) {
      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);
  Houston._publish(name, function(sort, filter, limit) {
    var e;
    check(sort, Object);
    check(filter, Object);
    check(limit, Number);
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    try {
      return collection.find(filter, {
        sort: sort,
        limit: limit
      });
    } catch (error) {
      e = error;
      return console.log(e);
    }
  });
  collection.find().observe({
    added: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: 1
        },
        $addToSet: {
          fields: {
            $each: Houston._get_field_names([document])
          }
        }
      });
    },
    removed: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: -1
        }
      });
    }
  });
  fields = Houston._get_field_names(collection.find().fetch());
  c = Houston._collections.collections.findOne({name});
  if (c) {
    return Houston._collections.collections.update(c._id, {
      $set: {
        count: collection.find().count(),
        fields: fields
      }
    });
  } else {
    return Houston._collections.collections.insert({
      name,
      count: collection.find().count(),
      fields: fields
    });
  }
};


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
Houston._setup_collection = function(collection) {
  var c, fields, methods, name;
  if (collection._name in ADDED_COLLECTIONS) {
    return;
  }
  name = collection._name;
  methods = {};
  methods[Houston._houstonize(`${name}_insert`)] = function(doc) {
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    return collection.insert(doc);
  };
  methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {
    if (!Houston._user_is_admin(this.userId)) {
      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._houstonize(`${name}_delete`)] = function(id, update_dict) {
    if (!Houston._user_is_admin(this.userId)) {
      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);
  Houston._publish(name, function(sort, filter, limit) {
    var e;
    check(sort, Object);
    check(filter, Object);
    check(limit, Number);
    if (!Houston._user_is_admin(this.userId)) {
      return;
    }
    try {
      return collection.find(filter, {
        sort: sort,
        limit: limit
      });
    } catch (error) {
      e = error;
      return console.log(e);
    }
  });
  collection.find().observe({
    added: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: 1
        },
        $addToSet: {
          fields: {
            $each: Houston._get_field_names([document])
          }
        }
      });
    },
    removed: function(document) {
      return Houston._collections.collections.update({name}, {
        $inc: {
          count: -1
        }
      });
    }
  });
  fields = Houston._get_field_names(collection.find().fetch());
  c = Houston._collections.collections.findOne({name});
  if (c) {
    return Houston._collections.collections.update(c._id, {
      $set: {
        count: collection.find().count(),
        fields: fields
      }
    });
  } else {
    return Houston._collections.collections.insert({
      name,
      count: collection.find().count(),
      fields: fields
    });
  }
};
```

Response:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)
    else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

  Meteor.methods methods

  Houston._publish name, (sort, filter, limit) ->
    check sort, Object
    check filter, Object
    check limit, Number
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

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

  fields = Houston._get_field_names(collection.find().fetch())
  c = Houston._collections.collections.findOne {name}
  if c
    Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
  else
    Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}


Prompt:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)
    else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

Response:
Meteor.methods methods

  Houston._publish name, (sort, filter, limit) ->
    check sort, Object
    check filter, Object
    check limit, Number
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

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

  fields = Houston._get_field_names(collection.find().fetch())
  c = Houston._collections.collections.findOne {name}
  if c
    Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
  else
    Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}


Response:
Houston._setup_collection = (collection) ->
  return if collection._name of ADDED_COLLECTIONS

  name = collection._name
  methods = {}
  methods[Houston._houstonize "#{name}_insert"] = (doc) ->
    return unless Houston._user_is_admin @userId
    collection.insert(doc)

  methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    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._houstonize "#{name}_delete"] = (id, update_dict) ->
    return unless Houston._user_is_admin @userId
    if collection.findOne(id)
      collection.remove(id)
    else
      id = collection.findOne(new Meteor.Collection.ObjectID(id))
      collection.remove(id)

  Meteor.methods methods

  Houston._publish name, (sort, filter, limit) ->
    return unless Houston._user_is_admin @userId
    try
      collection.find(filter, sort: sort, limit: limit)
    catch e
      console.log e

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

  fields = Houston._get_field_names(collection.find().fetch())
  c = Houston._collections.collections.findOne {name}
  if c
    Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
  else
    Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}
  ADDED_COLLECTIONS[name] = collection