여러 데이터 삭제

· 2019-02-12 (화) 23:47:18 · 3050 · 1

여러 데이터 삭제

 

둘 이상의 문서를 삭제하려면이 deleteMany()방법을 사용하십시오 .

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


주소가 문자 "O"로 시작하는 모든 문서를 삭제하십시오.

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: /^O/ };
  dbo.collection("customers").deleteMany(myquery, function(err, obj) {
    if (err) throw err;
    console.log(obj.result.n + " document(s) deleted");
    db.close();
  });
});

|

댓글 1개

2020-01-15 (수) 12:45:48
감사합니다.
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,403건

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

+
분류 제목 글쓴이 날짜 조회
PHP 19-06-24 조회 3,171
PHP 19-06-09 조회 3,782
MySQL 19-04-01 조회 4,835
jQuery 19-03-20 조회 4,229
node.js 19-02-12 조회 3,318
node.js 19-02-12 조회 3,051
node.js 19-02-12 조회 3,317
node.js 19-02-07 조회 3,286
node.js 19-02-07 조회 3,039
node.js 19-02-07 조회 3,169
node.js 19-02-04 조회 2,906
node.js 19-02-04 조회 2,896
node.js 19-02-04 조회 3,325
node.js 19-01-31 조회 2,436
node.js 19-01-31 조회 2,584
node.js 19-01-31 조회 3,079
node.js 19-01-28 조회 2,841
node.js 19-01-28 조회 2,924
node.js 19-01-28 조회 2,748
node.js 19-01-22 조회 3,090
node.js 19-01-22 조회 2,842
node.js 19-01-22 조회 3,277
node.js 19-01-16 조회 2,713
node.js
[node.js]
19-01-16 조회 2,623
node.js 19-01-16 조회 9,301
node.js 19-01-12 조회 4,364
node.js 19-01-12 조회 2,984
node.js 19-01-12 조회 3,112
node.js 19-01-11 조회 2,682
node.js 19-01-11 조회 3,999