From 40e788e01bf4c2fafad8ac6371671280e7c5139f Mon Sep 17 00:00:00 2001 From: AdithyakrishnaV Date: Thu, 1 Jul 2021 06:36:23 +0530 Subject: [PATCH] add mongoose models --- author.js | 13 +++++++++++++ book.js | 18 ++++++++++++++++++ publication.js | 13 +++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 author.js create mode 100644 book.js create mode 100644 publication.js diff --git a/author.js b/author.js new file mode 100644 index 0000000..2bb5e78 --- /dev/null +++ b/author.js @@ -0,0 +1,13 @@ +const mongoose = require("mongoose"); + +//Creating an author schema +const AuthorSchema = mongoose.Schema({ + id: Number, + name: String, + books:[String] +}); + +// Creating a model +const AuthorModel = mongoose.model(AuthorSchema); + +module.exports = AuthorModel; \ No newline at end of file diff --git a/book.js b/book.js new file mode 100644 index 0000000..4f418af --- /dev/null +++ b/book.js @@ -0,0 +1,18 @@ +const mongoose = require("mongoose"); + +//Creating a book schema +const BookSchema = mongoose.Schema({ + ISBN: String, + title: String, + pubDate: String, + language: String, + numPage: Number, + authors: [Number], + publication: [Number], + category: [String], +}); + +// Create a model +const BookModel = mongoose.model(BookSchema); + +module.exports = BookModel; \ No newline at end of file diff --git a/publication.js b/publication.js new file mode 100644 index 0000000..14a2250 --- /dev/null +++ b/publication.js @@ -0,0 +1,13 @@ +const mongoose = require("mongoose"); + +// Publication schema +const PublicationSchema = mongoose.Schema({ + id: Number, + name: String, + books:[String] +}); + +// Creating a model +const PublicationModel = mongoose.model(PublicationSchema); + +module.exports = PublicationModel; \ No newline at end of file