From 60719fcbe60d212b6c571b26efc82c7dc2f14336 Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra Date: Tue, 31 Jul 2018 01:36:56 +0530 Subject: [PATCH] feat(news): Add relations --- common/models/article.json | 13 ++++++++++++- common/models/popularity.json | 8 +++++++- common/models/user.json | 5 +++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/common/models/article.json b/common/models/article.json index cb735530b17..f3a425710ed 100644 --- a/common/models/article.json +++ b/common/models/article.json @@ -68,7 +68,18 @@ } }, "validations": [], - "relations": {}, + "relations": { + "user": { + "type": "belongsTo", + "model": "user", + "foreignKey": "externalId" + }, + "popularity": { + "type": "hasOne", + "model": "popularity", + "foreignKey": "popularityId" + } + }, "acls": [], "methods": {} } diff --git a/common/models/popularity.json b/common/models/popularity.json index fbad861e470..88a0c59a6a7 100644 --- a/common/models/popularity.json +++ b/common/models/popularity.json @@ -15,7 +15,13 @@ } }, "validations": [], - "relations": {}, + "relations": { + "article": { + "type": "belongsTo", + "model": "article", + "foreignKey": "articleId" + } + }, "acls": [], "methods": {} } diff --git a/common/models/user.json b/common/models/user.json index b26ce568521..b44149743f8 100644 --- a/common/models/user.json +++ b/common/models/user.json @@ -284,6 +284,11 @@ "options": { "disableInclude": true } + }, + "articles": { + "type": "hasMany", + "model": "article", + "foreignKey": "externalId" } }, "acls": [