From dde0af187b47e0af31f651ee14126a85060e4409 Mon Sep 17 00:00:00 2001 From: Atiqul Alam Rocky Date: Fri, 12 Jun 2020 23:08:22 +0600 Subject: [PATCH] BE #5: Change in article, fragment and revision model --- models/article.js | 2 +- models/fragment.model.js | 2 +- models/revision.model.js | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/models/article.js b/models/article.js index 650888e..fd5c4b6 100644 --- a/models/article.js +++ b/models/article.js @@ -11,7 +11,7 @@ var articleSchema = new Schema( type: String, require: true, }, - body: [String], + body: [{type: Schema.Types.ObjectId, ref: 'Fragment'}], author: { type: mongoose.Schema.Types.ObjectId, ref: 'User', diff --git a/models/fragment.model.js b/models/fragment.model.js index 0befea4..e9d4813 100644 --- a/models/fragment.model.js +++ b/models/fragment.model.js @@ -15,7 +15,7 @@ const fragmentSchema = new Schema({ }, ], //for type figure/image - metadata: { type: Schema.Types.ObjectId, ref: 'Image' }, + image: { type: Schema.Types.ObjectId, ref: 'Image' }, //for type 7 iframe iframe: { type: Schema.Types.ObjectId, ref: 'ExternalLink' }, //for embed any link diff --git a/models/revision.model.js b/models/revision.model.js index 15d0724..e069c8c 100644 --- a/models/revision.model.js +++ b/models/revision.model.js @@ -5,8 +5,10 @@ const revisionSchema = new Schema({ currentRevision: {type: Number, required: true}, revisions:[{ revision: {type: Number}, - frags:[{type: Schema.Types.ObjectId, ref: 'Fragment'}], - action: {type: String, enum:['add', 'delete'], default: 'add'} + frags:[{ + operationType:{type:String}, + fragment: {type: Schema.Types.ObjectId, ref: 'Fragment'} + }] }] });