nodeclub/proxy/relation.js
2013-02-20 02:37:35 +08:00

22 lines
625 B
JavaScript

var models = require('../models');
var Relation = models.Relation;
exports.getRelation = function (userId, followId, callback) {
Relation.findOne({user_id: userId, follow_id: followId}, callback);
};
exports.getRelationsByUserId = function (id, callback) {
Relation.find({follow_id: id}, callback);
};
exports.newAndSave = function (userId, followId, callback) {
var relation = new Relation();
relation.user_id = userId;
relation.follow_id = followId;
relation.save(callback);
};
exports.remove = function (userId, followId, callback) {
Relation.remove({user_id: userId, follow_id: followId}, callback);
};