_.filter(posts, function(post){
return post.user_id == 101;
}));
_.go(
_.filter(posts, function (post) {
return post.user_id == 101;
}),
function (posts) {
return _.filter(comments, function (comment) {
return _.find(posts, function (post) {
return post.id == comment.post_id; //posts안에 post_id가 있는가, 있으면 거르기
});
});
}, console.log
);
var f1 = _.pipe(posts_by, comments_by_posts);
console.log(f1( {user_id: 101 }));
_.go(
_.filter(posts, function (post) {
return post.user_id == 101;
}),
_.map(function(post) {
return post.id;
}),
function (post_ids) {
return _.filter(comments, function (comment) {
return _.contains(post_ids, comment.post_id);
//post_id 가 post_ids 에 포함되어 있는지
});
},
console.log
);
_.go(
_.where(posts, { user_id : 101 }),
_.pluck('id'),
function (post_ids) {
return _.filter(comments, function (comment) {
return _.contains(post_ids, comment.post_id);
//post_id 가 post_ids 에 포함되어 있는지
});
},
console.log
);
_.go(
_.where(posts, { user_id : 101 }),
_.pluck('id'),
function (post_ids) {
return _.filter(comments, function (comment) {
return _.contains(post_ids, comment.post_id);
//post_id 가 post_ids 에 포함되어 있는지
});
},
_.map(function (comment) {
return _.find(users, function(user) {
return user.id == comment.user_id;
}).name;
}),
_.uniq, //중복제거
console.log
);
var f2 = _.pipe(f1, comments_to_user_names, _.uniq);
console.log(f2({ user_id: 101 }));
function posts_by(attr) {
return _.where(posts, attr);
}
var comments_by_posts = _.pipe(
_.pluck('id'),
function(post_ids) {
return _.filter(comments, function(comment) {
return _.contains(post_ids, comment.post_id);
});
});
_.go(
posts_by({ user_id : 101 }),
comments_by_posts,
_.map(function (comment) {
return _.find(users, function(user) {
return user.id == comment.user_id;
}).name;
}),
_.uniq, //중복제거
console.log
);
_.go(
posts_by({ user_id : 101 }),
comments_by_posts,
_.map(function (comment) {
return _.find(users, function(user) {
return user.id == comment.user_id;
}).name;
}),
_.count_by, //카운트!
console.log
);
var comments_to_user_names = _.map(function(comment) {
return _.find(users, function(user) {
return user.id == comment.user_id;
}).name;
});
var f3 = _.pipe(f1, comments_to_user_names, _.count_by);
console.log(f3({ user_id: 101 }));
_.go(
_.where(comments, { user_id: 105 }),
console.log
);
_.go(
_.where(comments, { user_id: 105 }),
_.pluck('post_id'),
_.uniq,
function(post_ids) {
return _.filter(posts, function(post) {
return _.contains(post_ids, post.id);
});
},
console.log);
All your hard work is much appreciated. Nobody can stop to admire you. Lots of appreciation. thc dabs for sale
Your blog furnished us with important data to work with. Each and each tip of your post are amazing. You're the best for sharing. Continue blogging, 꽁머니 지급