Node.js MongoDB 삭제

· 2019-02-12 (화) 23:46:27 · 3332

Node.js MongoDB 삭제


문서 삭제


레코드를 삭제하거나 MongoDB에서 호출 된 문서를 삭제하기 위해이 deleteOne()메소드를 사용합니다 .

deleteOne()메서드 의 첫 번째 매개 변수는 삭제할 문서를 정의하는 쿼리 개체입니다.

 


 

var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  var dbo = db.db("mydb");
  var myquery = { address: 'Mountain 21' };
  dbo.collection("customers").deleteOne(myquery, function(err, obj) {
    if (err) throw err;
    console.log("1 document deleted");
    db.close();
  });
});

|
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,403건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
PHP 19-06-24 조회 3,181
PHP 19-06-09 조회 3,800
MySQL 19-04-01 조회 4,850
jQuery 19-03-20 조회 4,236
node.js 19-02-12 조회 3,335
node.js 19-02-12 조회 3,070
node.js 19-02-12 조회 3,333
node.js 19-02-07 조회 3,292
node.js 19-02-07 조회 3,052
node.js 19-02-07 조회 3,185
node.js 19-02-04 조회 2,920
node.js 19-02-04 조회 2,909
node.js 19-02-04 조회 3,342
node.js 19-01-31 조회 2,451
node.js 19-01-31 조회 2,597
node.js 19-01-31 조회 3,094
node.js 19-01-28 조회 2,855
node.js 19-01-28 조회 2,939
node.js 19-01-28 조회 2,765
node.js 19-01-22 조회 3,107
node.js 19-01-22 조회 2,851
node.js 19-01-22 조회 3,288
node.js 19-01-16 조회 2,719
node.js
[node.js]
19-01-16 조회 2,633
node.js 19-01-16 조회 9,312
node.js 19-01-12 조회 4,370
node.js 19-01-12 조회 2,988
node.js 19-01-12 조회 3,117
node.js 19-01-11 조회 2,692
node.js 19-01-11 조회 4,009