Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Sequelize allows you to extend models with additional functionality. Since Sequelize models are ES6 classes, you can easily add custom instance-level methods that encapsulate the functionality. In this video, you'll create helper methods to format an article's publish date and short description.
Code Snippets
publishedAt() {
const date = moment(this.createdAt).format("MMMM D, YYYY, h:mma");
return date;
}
shortDescription() {
const shortDesc = this.body.length > 200 ? this.body.substring(0, 200) + "..." : this.body;
return shortDesc;
}
Resources
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up