Git Product home page Git Product logo

my-mongodb's Introduction

my-MongoDB

安装mongodb并添加至系统变量,我的版本是3.4.0。

命令行下运行 MongoDB 服务器

    mongod --dbpath d:\MongoDB\db

将 MongoDB 添加到系统服务( 🌺 以管理员身份打开cmd)

    mongod --logpath D:\MongoDB\log\mongodb.log --logappend --dbpath D:\MongoDB\db --serviceName MongoDB --install

MongoDB后台管理 Shell

    mongo

查看当前操作的文档(数据库)

    db
    // 或者
    db.getName()

显示当前db状态

    db.stats()

列出所有db名称及占用情况(刚创建未添加数据的db不显示)

    show dbs

连接到test数据库

    use test

创建数据库( 🌺 如果数据库不存在,则创建数据库,否则切换到指定数据库。)

    use test

删除数据库( 🌺 删除当前数据库 )

    db.dropDatabase();

显示当前db中的集合

    show collections
    // 或
    db.getCollectionNames()

删除集合( 🌺 collection 简写为 col )

    db.col.drop()

集合中插入文档( 🌺 document 简写为 doc )

    db.col.insert(doc)
    // 或
    db.col.save(doc)

查看集合中的所有文档( 查看表中的数据 )

    db.col.find()

更新文档

    db.col.update(
        <query>,
        <update>,
        {
            upsert: <boolean>,
            multi: <boolean>,
            writeConcern: <boolean>
        }
    );

my-mongodb's People

Contributors

xinhualufang avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.