zoukankan      html  css  js  c++  java
  • MongoDB学习第六篇 --- Delete操作

    数据如下:

    db.inventory.insertMany( [
       { item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
       { item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "P" },
       { item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
       { item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
       { item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" },
    ]);

    一、shell操作delete语句

    db.inventory.deleteMany({})  # 删除所有 document
    db.inventory.deleteMany({ status : "A" })    # 删除所有 匹配到document
    db.inventory.deleteOne( { status: "D" } )   # 只删除第一个匹配的 document

    二、python操作delete语句

    db.inventory.delete_many({})
    db.inventory.delete_many({"status": "A"})
    db.inventory.delete_one({"status": "D"})

    三、java操作delete语句

    collection.deleteMany(new Document());
    collection.deleteMany(eq("status", "A"));
    collection.deleteOne(eq("status", "D"));
  • 相关阅读:
    netcore 报错 502 缺少运行时
    简单工厂模式
    net之-------状态模式
    pc端字体正常, 缩放浏览器正常,手机模式查看出问题
    我的后续情况
    [wip]Berty
    利用FileReader对象回显图片
    测试
    CMP云管平台竞标产品
    nacos spring cloud
  • 原文地址:https://www.cnblogs.com/malcolmfeng/p/6929271.html
Copyright © 2011-2022 走看看