수

여러 데이터 삭제

· 2019-02-12 (화) 23:47:18 · 3083 · 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,189
PHP 19-06-09 조회 3,810
MySQL 19-04-01 조회 4,863
jQuery 19-03-20 조회 4,248
node.js 19-02-12 조회 3,351
node.js 19-02-12 조회 3,084
node.js 19-02-12 조회 3,347
node.js 19-02-07 조회 3,325
node.js 19-02-07 조회 3,063
node.js 19-02-07 조회 3,210
node.js 19-02-04 조회 2,947
node.js 19-02-04 조회 2,921
node.js 19-02-04 조회 3,369
node.js 19-01-31 조회 2,477
node.js 19-01-31 조회 2,628
node.js 19-01-31 조회 3,106
node.js 19-01-28 조회 2,868
node.js 19-01-28 조회 2,951
node.js 19-01-28 조회 2,792
node.js 19-01-22 조회 3,121
node.js 19-01-22 조회 2,886
node.js 19-01-22 조회 3,309
node.js 19-01-16 조회 2,754
node.js
[node.js]
19-01-16 조회 2,649
node.js 19-01-16 조회 9,325
node.js 19-01-12 조회 4,403
node.js 19-01-12 조회 3,001
node.js 19-01-12 조회 3,152
node.js 19-01-11 조회 2,696
node.js 19-01-11 조회 4,051