UMFAQのように、作成/更新されたタイムスタンプを実装しようとしています。「作成された」タイムスタンプを機能させることができますが、コレクションに変換を追加すると、タイムスタンプが機能しなくなります。
Post = function (document) {
_.extend(this, document);
}
Post.prototype = {
constructor: Post,
formatDate: function () {
return this.due.toDateString();
}
}
Posts = new Meteor.Collection("post", {
transform: function (document) {
return new Post(document);
}
});
Posts.deny({
insert: function (userId, doc) {
doc.created = new Date(); // timestamp
return false;
}
});