Collections

Space Kitty follows all of the conventions set forth by the Meteor Guide. At it’s most simple, a Collection is:

Todos = new Mongo.Collection('Todos');

You can create this collection with Space Kitty with the simple command:

Command

kitty make:collection Todos

Output

Todos = new Mongo.Collection('Todos');

But Space Kitty goes beyond that, you can also pass in flags and get even more out of your collection:

Command

kitty make:collection Todos --with-schema --self-publishes

Output

/**
 * Todos
 */
Todos = new Mongo.Collection('todos');

var TodosSchema = new SimpleSchema({
   //
});

Todos.attachSchema(TodosSchema);Todos.allow({
   insert: function () {
     return false;
   },
   update: function () {
     return false;
   }
});

if ( Meteor.isServer ) {
   Meteor.publish('todos', function() {
     return Todos.find({
       //
     });
   });
 }

Or you can make a local collection:

Command

kitty make:collection Todos --local

Output

Todos = new Mongo.Collection(null);

By default, Space Kitty uses aldeed:simple-schema for generating schemas. The package is included with Space Kitty generated projects by default as well.

The last flag is for users who want to use classes for their schemas and extend the Mongo Collection:

Command

kitty make:collection Todos --class

Output

/**
 * Todos
 */
class TodosCollection extends Mongo.Collection {
  insert(list, callback) {
     //
  },
  update(selector, callback) {
    //
  },
  remove(selector, callback) {
    //
  }
}
Todos = new TodosCollection('todos');

 

Previous: Making Views

Next: Making Migrations