v1.1.21Published 11 months ago

project based on https://github.com/goooseman/default-collection-hooks

I just customized that project with audit on update, the rest is the same

Meteor Default Collection Hooks

Assings createdAt, createdBy, modifiedAt, modifiedBy attributes to any collection in one line of code.

Getting Started


meteor add splayerhd:default-collection-audit-hooks


var test = new Mongo.Collection("test");



opts is an object with the following options:

  • createdAt (default: true): create a createdAt field with current date on object create
  • createdBy (default: true): create a createdBy field with userId on object create (if there is any)
  • modifiedAt (default: true): create a modifiedAt field with current date on object update
  • modifiedBy (defulat: true): create a modifiedBy field with userId on object update (if there is any)

If you do not pass a options object, it will use the defaults. You can pass only the options you want to modify.


var test = new Mongo.Collection("test");


Will create createdAt, createdBy on object create and modifiedAt, modifiedBy attributes on object update.

var test = new Mongo.Collection("test");

  modifiedAt: false,
  modifiedBy: false

Will create createdAt, createdBy on object create, and do nothing on object update.

to publish

change the version in package.js then run

meteor publish