v0.0.2Published 3 years ago


quave:collections is a Meteor package that allows you to create your collections in a standard way.


  • Schemas
  • Types
  • Helpers
  • Hooks
  • Composers


Every application that connects to databases usually need the following features:

  • A way to access object instances when they come from the database: helpers
  • Provide new methods to collections: collection
  • Add a few hooks to react to changes in different collections: hooks
  • Map some types to avoid manual conversion all the time: types
  • Valid the data before persisting: schemas
  • Centralize behaviors: composers

Meteor has packages for almost all these use cases but it's not easy to find the best in each case and also how to use them together, that is why we have created this package.

We offer here a standard way for you to create your collections by configuring all these features in a function call createCollection using a bunch of options in a declarative way and without using Javascript classes.

We also allow you to extend your Meteor.users collection in the same way as any other collection.

We believe we are not reinventing the wheel in this package but what we are doing is like putting together the wheels in the vehicle :).


meteor add quave:collections

Optional installations

To use Type or Hooks options you need to install meteor-collection-hooks

meteor add matb33:collection-hooks

To use Schema options you need to install meteor-collection2

meteor add aldeed:collection2@3.0.0
meteor npm install --save simpl-schema

To use Helpers options you need to install meteor-collection-helpers

meteor add dburles:collection-helpers

Check the documentation of each package to learn how to use them.



1export const UsersCollection = createCollection({
2  instance: Meteor.users,
3  schema: UserSchema,
4  collection: {
5    isAdmin(userId) {
6      const user = userId && this.findOne(userId, { fields: { profiles: 1 } });
7      return (
8        user && user.profiles && user.profiles.includes(UserProfile.ADMIN.name)
9      );
10    },
11  },
12  helpers: {
13    toPaymentGatewayJson() {
14      return {
15        country: 'us',
16        external_id: this._id,
17        name: this.name,
18        type: 'individual',
19        email: this.email,
20      };
21    },
22  },
23  composers: [paginable],
24  apply(coll) {
25    coll.after.insert(userAfterInsert(coll), { fetchPrevious: false });
26    coll.after.update(userAfterUpdate);
27  },


  • You can't apply type and typeFields when you inform an instance of a MongoDB collection, usually you only use an instance for Meteor.users. In this case I would recommend you to don't add fields with custom types to the users documents.

  • If you want to use your objects from the database also in the client but you don't use your whole collection in client (you are not using Mini Mongo) you need to instantiate your type also in the client, you can do this importing your type and calling register. This is important to register it as an EJSON type.