Permalink
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (20 sloc) 467 Bytes

Create Behavior Class

var f = require('firenze');

var TimestampBehavior = f.createBehavior({
  beforeSave: function (model) {
    model.set('created', new Date());
    return new f.Promise(true);
  }
});

If you are using ES6, the syntax can be much simpler:

import {Behavior, Promise} from 'firenze';

class TimestampBehavior extends Behavior {
  beforeSave(model) {
    model.set('created', new Date());
    return new Promise(true);
  }
}