August Bjornberg
August Bjornberg

Reputation: 4976

KeystoneJS, tracking updatedBy/updatedAt

Been pulling my hair, google tells me nothing. Can't for the life of me understand how they intend 'track' to work.

From the documentation, I assumed it would be as straight forward as this:

Truth.add({
    title: { 
        type: Types.Textarea, 
        required: true 
    }
    track: {
        updatedBy: true
    }
});

However, the above solution renders this:

Error: Fields must be specified with a type function

All i want is for my model to store who last updated the item. Is this not how 'track' is intended to work? What am i missing...

Upvotes: 1

Views: 515

Answers (1)

happymilktea103
happymilktea103

Reputation: 81

You should define this in the list schema rather than the model fields.

You can either set track: true to enable all the meta fields or to an object for specific ones.

var Truth = new keystone.List('Truth', {
    track: true // Enables all field
    track: {updatedBy: true} // Enables updatedBy field only
});

These will then appear at the bottom of the item page.

Upvotes: 2

Related Questions