Database
-
[save, insertOne] - 데이터 저장Database/MongoDB 2022. 1. 21. 21:53
db.collection.save( ) 매개변수에 따라 새 문서 삽입 Starting in MongoDB 4.2, the db.collection.save( ) method is deprecated. Use db.collection.insertOne( ) or db.collection.replaceINe( ) instead MongoDB 4.2부터 db.collection.save( )메서드가 더 이상 사용되지 않는다. 대신 insertOne( ) 또는 replaaceOne( ) 사용 db.collection.insertOne( ) /* SQL 스키마 */ CREATE TABLE people ( id MEDIUMINT NOT NULL AUTO_INCREMENT, user_id Varchar(30), ag..
-
[Schema, model]Database/MongoDB 2022. 1. 20. 19:08
Shema 정의 mongoose의 모든 것은 Schema로부터 시작한다. 각 Schema는 MongoDB 컬렉션에 매핑되고 해당 컬렉션 내 문서의 모양 정의 하나하나 정보 지정한다. type, maxlength.. ShemaTypes String Number Date Buffer Boolean Mixed ObjectId Array Decimal128 Map 예시 // schema 예시 const productSchema = mongoose.Shema({ writer: { type: schema.Types.ObjectId, ref: 'User' }, title: { type: String, maxlength: 50 }, description: { type: String }, }, { timestamps: ..
-
[mongoose 설치]Database/MongoDB 2022. 1. 20. 16:55
몽고디비 사이트 접속 https://www.mongodb.com/ CLUSTER 만들기 => 무료 클러스터 생성 Mongo DB 유저 생성 cluster 생성 후 username과 password생성 Connect your application driver와 version 확인 후 아래 코드 복사 Mongoose 다운로드 npm install mongoose --save ( 패키지 설치 ) Mongoose NoSQL Database 몽고DB를 편하게 쓸 수 있는 Object Modeling Tool Node.js와 Mongo DB를 연결해주는 ODM (Object Document Mapping) 객체와 문서를 1대1 매칭하는 역할 관련 문서 참고 => https://mongoosejs.com/docs/a..