08

作者: drolor | 来源:发表于2016-09-19 10:00 被阅读0次

    插入张瓜赵四

    db.Person.insert({"name":"张瓜","age":10})WriteResult({"nInserted":1})

    db.Person.insert({"name":"赵四","age":20})WriteResult({"nInserted":1})

    查询张瓜

    > db.Person.find({"name":"张瓜"}){"_id":ObjectId("5617275737a5aa2cafdb4b84"),"name":"张瓜","age":10}>

    查询所有信息

    db.Person.find()

    {"_id":ObjectId("5617277b37a5aa2cafdb4b85"),"name":"赵四","age":20}{"_id":ObjectId("56172d069d1af21ad1f769c7"),"name":"张瓜","age":40}

    改张瓜年龄

    db.Person.update({"name":"张瓜"}, {"name":"张瓜","age":40})WriteResult({"nMatched":1,"nUpserted":0,"nModified":1})

    查询张瓜此时年龄变成40

    db.Person.find({"name":"张瓜"})                                          {"_id":ObjectId("56172d069d1af21ad1f769c7"),"name":"张瓜","age":40}

    删除

    db.Person.remove({"name":"张瓜"})WriteResult({"nRemoved":1})>

    db.Person.find()

    此时已删除张瓜,显示赵四信息

    {"_id":ObjectId("5617277b37a5aa2cafdb4b85"),"name":"赵四","age":20}

    相关文章

      网友评论

          本文标题:08

          本文链接:https://www.haomeiwen.com/subject/wgogettx.html