zoukankan      html  css  js  c++  java
  • Mongo技巧-连接数据库与修改表结构

    1. 连接非本机数据库

    mongo.exe之后直接输入ip地址即可

    mongo.exe 192.168.163.203
    

    2. 修改表结构

    mongo里面没有表结构这个概念,现在采用类似关系型数据库的形式来描述。如果想去掉collection里面的一个key,可以采用以下命令:

    db.UserEntity.update({},{$unset:{Mail:1}},false,true);
    

    上面的命令从表UserEntity中删除一个字段Mail。

    关于unset的具体说明

    $unset
    The $unset operator deletes a particular field. Consider the following syntax:
    
    { $unset: { <field1>: "", ... } }
    The specified value in the $unset expression (i.e. "") does not impact the operation.
    
    To specify a <field> in an embedded document or in an array, use dot notation.
    
    Behavior
    
    If the field does not exist, then $unset does nothing (i.e. no operation).
    
    When used with $ to match an array element, $unset replaces the matching element with null rather than removing the matching element from the array. This behavior keeps consistent the array size and element positions.
    
    Example
    
    The following update() operation uses the $unset operator to remove the fields quantity and instock from the first document in the products collection where the field sku has a value of unknown.
    
    db.products.update(
       { sku: "unknown" },
       { $unset: { quantity: "", instock: "" } }
    )
    SEE ALSO
    
  • 相关阅读:
    (OK) Fedora 24 开机自动启动脚本
    (OK)(OK) houshoul experiment
    centos-quagga-ospf6d.conf
    使用 Quagga 将你的 CentOS 变成 OSPF 路由器
    docker中安装quagga
    (OK) paper-5_mobicom_acm_latex.txt
    (OK) Latex
    Latex的几种参考文献排序
    Inkscape Tutorial Effects: Placing an Image Inside a Shape – Part 2
    Latex中图形的引用和插入
  • 原文地址:https://www.cnblogs.com/wardensky/p/4932341.html
Copyright © 2011-2022 走看看