본문 바로가기

부엉이의 정보 창고97

몽고 DB 기초 6 Comparison With Relational Database Relational DB : SQL Create two different tables and tangle them with SQL. MongoDB : No-SQL Create two different objects and nest. const mongoose = require('mongoose') const Schema = mongoose.Schema const BookSchema = new Schema({ title: String, pages: Number }) const AuthorScheam = new Schema({ name: String, age: Number, book: [BookSchema] // nested }) // mong.. 2022. 1. 11.
몽고 DB 기초 5 Login and Hash Database : MongoDB Client : Advanced REST client Password encryption : npm bcrypt library Checking user info in collection(before password hashing User password after hashing User login failed with wrong password Token With json web token npm library, a token is created like below. const token = jsonWebToken.sign(user._id.toHexString(), 'myToken') Client : setting the token into c.. 2022. 1. 10.
몽고 DB 기초 4 Testing With Mocha Mocha is a testing framework used to make test cases. Running tests consistently ensures newly added features are well integrated with previous ones. You can test such as : Creating records Reading records Updating records Deleting records Install Mocha like below npm install mocha --save // Installing mocha is not required for production setting. npm install mocha --save-dev .. 2022. 1. 7.
몽고 DB 기초 3 CRUD in MongoDB Inserting, searching, updating, and deleting are asynchronous actions in database. The 'done' callback function should be called once the asynchronous operations are done. // done callback convention in Node.js const doSomething = function (done) { if (err) return done(err) done(null, result) } Types of Mongoose CRUD methods are as follows(cb : short for callback) : mongoose.Sche.. 2022. 1. 6.
몽고 DB 기초 2 Schema, Collection, And Model In creating database, the first thing we need is to create a schema. Each schema maps to a MongoDB collection. Schema => Collection => Model ===(instantiation)===> Document In MongoDB, a lot of databases can exist. Choose the one that you need and connect it using mongoose. Database is structured as follows What is schema? Model : a list of concepts describing data(.. 2022. 1. 5.
몽고 DB 기초 1 MongoDB is a NO-SQL database that stores JSON documents. Mongoose is a npm package used to control MongoDB with Javascript, creating schemas. SQL : saving all data across tables NO-SQL : saving all data within one record MongoDB has a merit combinated with Javascript that its format is JSON, which is Javascript Object Notation. Web - Server - Database Web client : HTML, CSS, Javascript Web serve.. 2022. 1. 4.

loading