0

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;
    }
});
4

1 に答える 1

4

サーバー側で変換しないでください:

if(Meteor.isClient) {
    Posts = new Meteor.Collection("post", {
        transform: function (document) {
        return new Post(document);
    }
}

if(Meteor.isServer) {
    Posts = new Meteor.Collection("post");
}
于 2013-05-22T20:44:08.847 に答える