Skip to content

Latest commit

 

History

History
43 lines (24 loc) · 1.55 KB

API.md

File metadata and controls

43 lines (24 loc) · 1.55 KB

LikeableModel (Abstract Class)

LikeableModel is used to create models with liking, starring, or favoriting capabilities. Since it is an abstract class, you extend it and then must pass in another class for it to extend itself from. LikeableModel is specifically designed to extend LinkParent from socialize:linkable-model. LinkParent extends BaseModel and thus all of it's functionality will be available on your new class.

Instance Methods

All examples assume an instance of a class that extends LikeableModel named like

like() - Like an instance of the model.

unlike() - Unlike an instance of the model.

likes() - Returns a cursor of Like instances.

isLikedBy(user) - check if a particular user likes this instance of a model.

Like - Extends LinkableModel##

A like is a record of a user liking an instance of a model with a reference to that instance.

Instance Methods

All examples assume an instance of Like named like

user() - get a User instance for the user that created the like.

like.user(); //=> {_id:"xxxxx", username:"johnDoe"}

isDuplicate() - check to see if a user has already liked the linked object.

like.isDuplicate(); => true

Publications

socialize.likesFor(linkedObjectId, options = { limit: 10, sort: { createdAt: -1 } }) - Publishes the likes and their related data for a certain object.

Meteor.subscribe('socialize.likesFor', post._id, { limit: 5, skip: 2 });