Skip to content

Commit

Permalink
Connect mongodb + create SourceMap model
Browse files Browse the repository at this point in the history
  • Loading branch information
nehal96 committed Jul 22, 2019
1 parent ef1e93b commit 8a69e24
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules
.DS_Store

# config
config/dev.js
1 change: 1 addition & 0 deletions config/keys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("./dev.js");
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
const express = require("express");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const keys = require("./config/keys");

// Require models
require("./models/SourceMap");

const app = express();

mongoose.connect(
keys.mongoURI,
{ useNewUrlParser: true }
);

app.use(bodyParser.json());

app.get("/", (req, res) =>
Expand Down
18 changes: 18 additions & 0 deletions models/SourceMap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const mongoose = require("mongoose");
const { Schema } = mongoose;

const sourceToContentInfoSchema = new Schema({
mediaId: String,
contentId: {
type: Schema.Types.ObjectId,
ref: "Content"
}
});

const sourceMapSchema = new Schema({
name: String,
url: String,
availableContent: [sourceToContentInfoSchema]
});

mongoose.model("sourceMaps", sourceMapSchema);

0 comments on commit 8a69e24

Please sign in to comment.