Skip to content

Commit

Permalink
BE #5: Add new sample schema for External link and it is not complete…
Browse files Browse the repository at this point in the history
… yet.
  • Loading branch information
Atiqul Alam Rocky committed May 30, 2020
1 parent a22fd8d commit 5e77d66
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
8 changes: 8 additions & 0 deletions models/external.link.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var mongoose = require('mongoose')
const Schema = mongoose.Schema
const externalLinkSchema = new Schema({
title: { type: String },
source: { type: String },
})

const ExternalLink = mongoose.model('ExternalLink', externalLinkSchema)
34 changes: 18 additions & 16 deletions models/fragment.model.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const mongoose = require('mongoose')
const Schema = mongoose.Schema

const fragmentSchema = new Schema({
articleid: {type: String, require: true},
tag: {type: String, require: true}, //'div/p/h3/h4/blockquote/figure/iframe'
name: {type: String, require: true}, //unique for an article,
text: {type: String, index: true}, //'textContent', (for type image it is caption)
markups:[{
tag: {type: String}, //'strong/em/a', (1:Bold, 2:italic, 3:anchor)
startAt: {type: Number}, //start Tag Position,
endAt: {type: Number}, //end Tag Position,
href:{type: String} // for anchore urlString
}],
articleid: { type: String, require: true },
tag: { type: String, require: true }, //'div/p/h3/h4/blockquote/figure/iframe'
name: { type: String, require: true }, //unique for an article,
text: { type: String, index: true }, //'textContent', (for type image it is caption)
markups: [
{
tag: { type: String }, //'strong/em/a', (1:Bold, 2:italic, 3:anchor)
startAt: { type: Number }, //start Tag Position,
endAt: { type: Number }, //end Tag Position,
href: { type: String }, // for anchore urlString
},
],
//for type figure/image
metadata:{type: Schema.Types.ObjectId, ref: 'Images'},
metadata: { type: Schema.Types.ObjectId, ref: 'Image' },
//for type 7 iframe
iframe:{type: Schema.Types.ObjectId, ref: 'ExternalLinks'},
iframe: { type: Schema.Types.ObjectId, ref: 'ExternalLink' },
//for embed any link
externalResource:{type: Schema.Types.ObjectId, ref: 'ExternalLinks'}
externalResource: { type: Schema.Types.ObjectId, ref: 'ExternalLink' },
})

const Fragment = mongoose.model('Fragment', fragmentSchema);
const Fragment = mongoose.model('Fragment', fragmentSchema)

0 comments on commit 5e77d66

Please sign in to comment.