• NOSQL -- Mongodb的简单操作与使用(win10)


                             NOSQL -- Mongodb的简单操作与使用(wins)

    MongoDB 创建集合:  

    db.createCollection(name, options)
    use huhu
    db.createCollection("hehe")
    show collections


    db.hehe.insert({"name":"meiLinYa"})
    

    show collections

    MongoDB 删除集合:

    show collections
    db.hehe.drop()
    show collections


    MongoDB 插入文档:

    db.user.insert({title: 'MongoDB', 
        description: 'MongoDB 是一个 Nosql 数据库',
        by: 'hehe',
        url: 'http://www.runoob.com/mongodb/mongodb-insert.html',
        tags: ['mongodb', 'database', 'NoSQL'],
        likes: 100
    })


    MongoDB 更新文档:

    db.user.update(
        {'title':'MongoDB'},
        {$set:{'title':'hehe'}}
        )
        
    db.user.find().pretty() 
    

    db.user.save({
        "_id" : ObjectId("5b2798f7d159ff618fb1bc91"),
        "title" : "MongoDB",
        "description" : "MongoDB 是一个 Nosql 数据库",
        "by" : "Runoob",
        "url" : "http://www.runoob.com",
        "tags" : [
                "mongodb",
                "NoSQL"
        ],
        "likes" : 110
    })
    db.user.find().pretty()


    MongoDB 删除文档:

    db.user.find();
    db.user.remove({'title':'MongoDB'})
    db.user.find();


    如果你只想删除你找到的第一天数据时:

    db.COLLECTION_NAME.remove(DELETION_CRITERIA,1)

    删除你找到的第一条数据。

    remove则可以当作删除所有数据

    db.user.remove({})
  • 相关阅读:
    0环与3环通信
    NACTF Encoder
    内核空间与内核模块
    Reserve ctf SSE_KEYGENME VAX2学习
    Inf2Cat Tool Output: ........................ Signability test failed.
    wustctf2020_closed
    ciscn_2019_final_5
    ciscn_2019_en_3 tcache
    内核编程基础
    保护模式阶段测试说明
  • 原文地址:https://www.cnblogs.com/meiLinYa/p/9222672.html
Copyright © 2020-2023  润新知