AllenYuan

article model favorited

May 11th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //...
  2.  
  3. // return the data of our article
  4. ArticleSchema.methods.toJSONFor = function(user) {
  5.   return {
  6.     slug: this.slug,
  7.     title: this.title,
  8.     description: this.description,
  9.     body: this.body,
  10.     createdAt: this.createdAt,
  11.     updatedAt: this.updatedAt,
  12.     tagList: this.tagList,
  13.     favorited: user ? user.isFavorite(this._id) : false,
  14.     favoritesCount: this.favoritesCount,
  15.     author: this.author.toProfileJSONFor(user)
  16.   };
  17. };
  18.  
  19. ///...
Advertisement
Add Comment
Please, Sign In to add comment