tm-apps-db
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -23,17 +23,5 @@ "use strict"; | ||
article_content.belongsTo(models.image, { | ||
article_content.belongsTo(models.content_item, { | ||
constraints: false | ||
}); | ||
article_content.belongsTo(models.html, { | ||
constraints: false | ||
}); | ||
article_content.belongsTo(models.video, { | ||
constraints: false | ||
}); | ||
article_content.belongsTo(models.gallery, { | ||
constraints: false | ||
}); | ||
} | ||
@@ -40,0 +28,0 @@ }, |
@@ -17,9 +17,2 @@ "use strict"; | ||
allowNull: false | ||
}, | ||
relation_id: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
validate: { | ||
is: /^(regionals|nationals)\.[0-9]+$/ | ||
} | ||
} | ||
@@ -31,18 +24,4 @@ }, { | ||
associate: function (models) { | ||
article_relation.belongsTo(models.image, {constraints: false}); | ||
article_relation.belongsTo(models.video, {constraints: false}); | ||
article_relation.belongsTo(models.gallery, {constraints: false}); | ||
article_relation.belongsTo(models.html, {constraints: false}); | ||
}, | ||
reassignRelationId: function(relationId, modelName, options) { | ||
return article_relation.findAll(R.merge(options, { | ||
where: { | ||
relation_id: relationId | ||
} | ||
})).then(relations => { | ||
return sequelize.Promise.all(R.map(relation => { | ||
const x = relation.get({plain: true}); | ||
return article_relation.upsert(R.assoc(`${modelName}_id`, x.relation_id, x), options); | ||
}, relations)) | ||
}) | ||
article_relation.belongsTo(models.article, {constraints: false}); | ||
article_relation.belongsTo(models.content_item, {constraints: false}); | ||
} | ||
@@ -53,5 +32,2 @@ }, | ||
fields: ['article_id'] | ||
}, | ||
{ | ||
fields: ['relation_id'] | ||
} | ||
@@ -58,0 +34,0 @@ ] |
@@ -36,18 +36,6 @@ "use strict"; | ||
associate: function (models) { | ||
gallery.belongsToMany(models.section, { | ||
through: 'sections_relations', | ||
constraints: false | ||
}); | ||
gallery.belongsTo(models.section, { | ||
constraints: false, as: 'home_section' | ||
}); | ||
gallery.hasMany(models.gallery_content, { | ||
constraints: false | ||
}); | ||
gallery.hasMany(models.article_relation, { | ||
constraints: false | ||
}); | ||
gallery.belongsToMany(models.section, {through: 'sections_relations', constraints: false}); | ||
gallery.belongsTo(models.section, {constraints: false, as: 'home_section'}); | ||
gallery.hasMany(models.gallery_content, {constraints: false}); | ||
gallery.hasOne(models.content_item, {constraints: false}); | ||
} | ||
@@ -54,0 +42,0 @@ }, |
@@ -40,3 +40,3 @@ "use strict"; | ||
html.belongsTo(models.section, {constraints: false, as: 'home_section'}); | ||
html.hasMany(models.article_relation, {constraints: false}); | ||
html.hasOne(models.content_item, {constraints: false}); | ||
} | ||
@@ -43,0 +43,0 @@ } |
@@ -53,4 +53,4 @@ "use strict"; | ||
image.belongsToMany(models.section, {through: 'sections_relations', constraints: false}); | ||
image.hasMany(models.article_relation, {constraints: false}); | ||
image.belongsTo(models.section, {constraints: false, as: 'home_section'}); | ||
image.hasOne(models.content_item, {constraints: false}); | ||
} | ||
@@ -57,0 +57,0 @@ } |
@@ -46,3 +46,3 @@ "use strict"; | ||
video.belongsTo(models.section, {constraints: false, as: 'home_section'}); | ||
video.hasMany(models.article_relation, {constraints: false}); | ||
video.hasOne(models.content_item, {constraints: false}); | ||
} | ||
@@ -49,0 +49,0 @@ } |
{ | ||
"name": "tm-apps-db", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Apps consumer database initialiser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
29732
28
806