data modeling

Gaurav GhugeGaurav Ghuge
2 min read

Table of contents

today we did the 3 week ago lecture of hitesh chaudhari sir on backend. we learn today the data modeling and asssignment for writing the controllers and routers in video player project.

data modeling is very easy concept by hitesh sir

first we import statement for import statement for mongoose that supports the MONGODB database and connect

import statement is the module JavaScript for importing or requiring the mongoose statements

In normal JavaScript we write the require statements like below

const mongoose = require('mongoose');

const express = require('express');

In module JavaScript we use import statements like below

import mongoose from 'mongoose';

import mongoose, {Schema} from 'mongoose';

above this are two approaches for use the module JavaScript and we use the Schema in data modeling

we write the comment Schema for video player project that are below

import mongoose,{Schema} from 'mongoose';

import 'mongooseAggregate-paginate-v2' from 'cloudinary'

const commentSchema = new Schema({

content: {

type: String,

required: true

},

video: {

type: Schema.Type.ObjectId,

ref: "video"

},

owner: {

type: Schema.Type.ObjectId,

ref: "User"

}

}, {timestamps: true})

export const comment = mongoose.model("comment", commentschema);

this are some demo of the data modeling for a video player project and the comments are main topic for data modeling

timestamps: true are the give the createdAt and updatedAt this properties of the video and use and that which is give the Schema that we define.

0
Subscribe to my newsletter

Read articles from Gaurav Ghuge directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Gaurav Ghuge
Gaurav Ghuge

i am student from the bsc computer science in 2nd year and i completed full stact web developer course and mern stack developer