수

여러 데이터 삭제

· 2019-02-12 (화) 23:47:18 · 3088 · 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,193
PHP 19-06-09 조회 3,812
MySQL 19-04-01 조회 4,867
jQuery 19-03-20 조회 4,252
node.js 19-02-12 조회 3,353
node.js 19-02-12 조회 3,089
node.js 19-02-12 조회 3,352
node.js 19-02-07 조회 3,327
node.js 19-02-07 조회 3,065
node.js 19-02-07 조회 3,211
node.js 19-02-04 조회 2,950
node.js 19-02-04 조회 2,927
node.js 19-02-04 조회 3,371
node.js 19-01-31 조회 2,479
node.js 19-01-31 조회 2,629
node.js 19-01-31 조회 3,107
node.js 19-01-28 조회 2,870
node.js 19-01-28 조회 2,952
node.js 19-01-28 조회 2,794
node.js 19-01-22 조회 3,124
node.js 19-01-22 조회 2,886
node.js 19-01-22 조회 3,310
node.js 19-01-16 조회 2,755
node.js
[node.js]
19-01-16 조회 2,651
node.js 19-01-16 조회 9,327
node.js 19-01-12 조회 4,404
node.js 19-01-12 조회 3,006
node.js 19-01-12 조회 3,153
node.js 19-01-11 조회 2,696
node.js 19-01-11 조회 4,052