본문 바로가기
반응형

create4

[Mongoose] Create관련, 차이점 Model.prototype.save(), Model.create(), Model.insertMany(), Model.bulkWrite(), Model.bulkSave Create관련Mongoose : Model.prototype.save(), Model.create(), Model.insertMany(), Model.bulkWrite(), Model.bulkSave 1. Model.prototype.save()document.isNew가 true인 경우 데이터베이스에 새 문서를 삽입하여 이 문서를 저장한다. isNew가 false인 경우 수정된 경로만 포함하는 updateOne 작업을 보낸다. 2. Model.create()하나 이상의 문서를 데이터베이스에 저장하기 위한 바로 가기이다.MyModel.c.. 2023. 2. 27.
[MongoDB] Create관련, 차이점 db.collection.insertOne(), db.collection.insertMany(), db.collection.bulkWrite() Create관련 MongoDB: db.collection.insert(): 지원중지, db.collection.save(): 지원중지, db.collection.insertOne(), db.collection.insertMany(), db.collection.bulkWrite() 1. db.collection.insertOne() InsertOne은 컬렉션에 단일 문서를 삽입하기 위해 삽입 명령을 실행한다. 문서 매개변수는 삽입할 문서여야 하고 0일 수 없다. 문서가 BSON으로 변환될 때 _id 필드가 없으면 마샬링된 문서에 자동으로 추가된다. (원본 문서는 .. 2023. 2. 27.
[MongoDB] CRUD 관련 모음(Bulk포함) [MongoDB] Create(생성), Read(조회), Update(변경), Delete(삭제)_Bulk포함 1. Create(생성) db.collection.insertOne(), db.collection.insertMany(), db.collection.bulkWrite(), Bulk.insert() 2. Read(조회) db.collection.find(), db.collection.findOne(), Bulk.find() 3. Update(변경) db.collection.findOneAndUpdate(), db.collection.updateOne(), db.collection.updateMany(), db.collection.findOneAndReplace(), db.collection.rep.. 2023. 2. 25.
[Mongoose] Model (CRUD 관련) 모음 [Mongoose] Model_Create(생성), Read(조회), Update(변경), Delete(삭제) 관련 1. 일반적인 CRUD 작업 Create: Model.create(), Model.insertMany(), Model.prototype.save() Read: Model.find() Update: Model.updateOne(), Model.updateMany(), Model.replaceOne() Delete: Model.deleteMany(), Model.deleteOne() 2. _Id로 find() 이후 작업 Read: Model.findById() Update: Model.findByIdAndUpdate() Delete: Model.findByIdAndDelete(), Model... 2023. 2. 25.
반응형