search

Home  >  Q&A  >  body text

mongodb - mogodb的简易教程,能够用到常用的命令?

mogodb的学习资料,不是文档什么的,那些直接google一堆,有点深度和实用的,另外有好的工具推荐么,比如Rockmongo之类的

ringa_leeringa_lee2757 days ago801

reply all(4)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-02 09:19:56

    Basic operations of database

    The most commonly used command in Mongo...should be this:

    mongo  yourMongoIP:yourMongoPort

    Mongo database connection instructions. My client is shell...

    After connecting to the database, there are Three major commands:

    show  dbs  //查看当前database
    use yourdbname  //使用yourdbname
    show collections  //查看当前collection
    

    The next step is the basic operations

    db.yourCollectionsName.find/delete/remove/count  
    

    Note: Delete and remove will have different restrictions depending on the version of MongoDB. However, when used, the command line will prompt whether this command is expired or not supported

    Advanced ones include:

    db.yourCollectionsName.aggregate/mapreduce

    Note: Basically basic commands + aggregate can satisfy 90% of query commands. Because mapreduce directly executes js code, the efficiency will be much lower, so try to avoid it.

    Database operation and maintenance

    There are many operations involved in operation and maintenance, such as replica sets, sharding, indexes...

    Recommend reading this article for replica sets and sharding: Building a Highly Available MongoDB Cluster (4) - Sharding

    Index is very important, be sure to cover all queries! However, too many indexes will take up disk and insertion time. You can refer to the official documentation for use. Here is a point, When creating an index, you must remember to create it in the background, otherwise the database will be locked...

    Database driver

    In addition to using the command line, Mongo also provides multiple language drivers. The most troublesome C++, it took a long time to compile orz. I use pymongo for python, and I use mongodb+monk for js.

    As for tools, I have never used them. The way I first learned it was that I really just read the three major commands and then used them. The rest were based on specific requirements, and I pieced together appropriate query statements from various Google and official websites. After understanding the basic operations, read the official documents again and optimize again. Well, so if possible, I still recommend that you go to the official website if you have any questions, and don't take many detours like me.

    Hope it can be helpful to you, O(∩_∩)O~

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-02 09:19:56

    Tutorial for newbies, first recommendation: http://www.runoob.com/mongodb/mongodb-tu...

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-02 09:19:56

    http://www.cnblogs.com/huangxincheng/arc... Materials for novice tutorials. Getting started is fine.

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-02 09:19:56

    nodejs tools use mongoose

    reply
    0
  • Cancelreply