Node.js MongoDB 삭제

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

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,167
PHP 19-06-09 조회 3,782
MySQL 19-04-01 조회 4,830
jQuery 19-03-20 조회 4,226
node.js 19-02-12 조회 3,316
node.js 19-02-12 조회 3,047
node.js 19-02-12 조회 3,315
node.js 19-02-07 조회 3,281
node.js 19-02-07 조회 3,034
node.js 19-02-07 조회 3,167
node.js 19-02-04 조회 2,904
node.js 19-02-04 조회 2,893
node.js 19-02-04 조회 3,325
node.js 19-01-31 조회 2,436
node.js 19-01-31 조회 2,582
node.js 19-01-31 조회 3,077
node.js 19-01-28 조회 2,841
node.js 19-01-28 조회 2,921
node.js 19-01-28 조회 2,745
node.js 19-01-22 조회 3,088
node.js 19-01-22 조회 2,838
node.js 19-01-22 조회 3,273
node.js 19-01-16 조회 2,710
node.js
[node.js]
19-01-16 조회 2,620
node.js 19-01-16 조회 9,295
node.js 19-01-12 조회 4,363
node.js 19-01-12 조회 2,984
node.js 19-01-12 조회 3,111
node.js 19-01-11 조회 2,682
node.js 19-01-11 조회 3,999