Posts

Showing posts from June 20, 2018

Create database schema in NODE JS example

In this article, I will explain how to create database schema in Node js application. So as a database, I will use MongoDB, it is very compatible with Node JS because MongoDB stores data in JSON format. In this example, I will create a  schema of student’s detail for MongoDB In action to create database schema, first create a folder models inside the application. This is the good practice to write all schemas in separate folder. Once you created models folder, create a student.js file. Steps: 1)       Create a folder models in application. 2)       Create Student.js file inside the models folder. 3)       Copy and paste below code in Student.js file const mongoose=require('mongoose'); const Schema= require('mongoose').Schema; const studentSchema = mongoose.Schema({     name:{         type:String,         required:true,         unique:true     },     class:{         type:String,         required:true,         unique:false  

Recent Post

Recent Posts Widget