summaryrefslogtreecommitdiff
path: root/src/api/endpoints/posts/favorites
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-03-28 16:39:14 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-03-28 16:39:14 +0900
commit3d5cdb8d2d60932caf1d29b0581c7d6243e06e37 (patch)
tree9c29d1062b08378d4c4cafe5976793616d45bc01 /src/api/endpoints/posts/favorites
parentwip (diff)
downloadsharkey-3d5cdb8d2d60932caf1d29b0581c7d6243e06e37.tar.gz
sharkey-3d5cdb8d2d60932caf1d29b0581c7d6243e06e37.tar.bz2
sharkey-3d5cdb8d2d60932caf1d29b0581c7d6243e06e37.zip
wip
Diffstat (limited to 'src/api/endpoints/posts/favorites')
-rw-r--r--src/api/endpoints/posts/favorites/create.ts16
-rw-r--r--src/api/endpoints/posts/favorites/delete.ts10
2 files changed, 13 insertions, 13 deletions
diff --git a/src/api/endpoints/posts/favorites/create.ts b/src/api/endpoints/posts/favorites/create.ts
index f9dee271b5..6100e10b23 100644
--- a/src/api/endpoints/posts/favorites/create.ts
+++ b/src/api/endpoints/posts/favorites/create.ts
@@ -13,9 +13,9 @@ import Post from '../../../models/post';
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
- // Get 'post_id' parameter
- const [postId, postIdErr] = $(params.post_id).id().$;
- if (postIdErr) return rej('invalid post_id param');
+ // Get 'postId' parameter
+ const [postId, postIdErr] = $(params.postId).id().$;
+ if (postIdErr) return rej('invalid postId param');
// Get favoritee
const post = await Post.findOne({
@@ -28,8 +28,8 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// if already favorited
const exist = await Favorite.findOne({
- post_id: post._id,
- user_id: user._id
+ postId: post._id,
+ userId: user._id
});
if (exist !== null) {
@@ -38,9 +38,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Create favorite
await Favorite.insert({
- created_at: new Date(),
- post_id: post._id,
- user_id: user._id
+ createdAt: new Date(),
+ postId: post._id,
+ userId: user._id
});
// Send response
diff --git a/src/api/endpoints/posts/favorites/delete.ts b/src/api/endpoints/posts/favorites/delete.ts
index c4fe7d3234..b1b4fcebc4 100644
--- a/src/api/endpoints/posts/favorites/delete.ts
+++ b/src/api/endpoints/posts/favorites/delete.ts
@@ -13,9 +13,9 @@ import Post from '../../../models/post';
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
- // Get 'post_id' parameter
- const [postId, postIdErr] = $(params.post_id).id().$;
- if (postIdErr) return rej('invalid post_id param');
+ // Get 'postId' parameter
+ const [postId, postIdErr] = $(params.postId).id().$;
+ if (postIdErr) return rej('invalid postId param');
// Get favoritee
const post = await Post.findOne({
@@ -28,8 +28,8 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// if already favorited
const exist = await Favorite.findOne({
- post_id: post._id,
- user_id: user._id
+ postId: post._id,
+ userId: user._id
});
if (exist === null) {