• mongo学习笔记


    1. show dbs #显示所有的数据库
    2. use user #进入 user数据库
    3. db #展示当前数据库
    4. show collections #显示数据库中的集合, 相当于表格
    5. db.runCommand({"dropDatabase":1}) /db.dropDatabase() #删除当前数据库
    ---------------------------------------------------------------------------
    6. db.user.save({"name":"hailong"}) #新增一条数据 有更新的作用 user表示集合 相当于表 use user 中的user表示库
    db.user.insert({"name":"hailong"}) #插入一条数据 单条或多条
    db.user.insertOne() #将单个文档插入到集合中
    db.user.insertMany() #将多个文档插入到集合中
    7. db.user.find() #查找集合中所有数据
    db.user.findOne() #查找集合中第一条数据 条件查找
    8. db.user.remove({"name":"hailong"}) #删除集合下 name=hailong的信息
    9. db.user.updata({"name":"hailong"},{"age":"12"}) #只会修改一条数据

    10. db.doctor.drop() 或 db.runCommand({"drop":"doctor"}) #删除doctor集合

    11. 封顶集合 自动删除早期的数据


    12. map reduce
    $collection = Yii::$app->mongodb->getCollection('score');
    $r = $collection->mapReduce('function () {emit(this.name,this.score);}', 'function (name, score) {return Array.sum(score);}','mapReduceScore');

    If the copyright belongs to the longfei, please indicate the source!!!
  • 相关阅读:
    switch选择结构
    变量与数据类型
    if选择结构
    NewSQL数据库VoltDB特性简介
    关系代数的并行计算
    【伯乐在线】程序员一定要投资的那些事
    Spark on Yarn
    六星经典CSAPP笔记(1)计算机系统巡游
    程序员的“机械同感”
    Impala中的代码生成技术
  • 原文地址:https://www.cnblogs.com/longfeiPHP/p/15557403.html
Copyright © 2020-2023  润新知