zoukankan      html  css  js  c++  java
  • 6.30MongoDB之$type操作符

    6.30MongoDB之$type操作符

    $type操作符是基于BSON类型来检索集合中匹配的数据类型,并返回结果。

    MongoDB 中可以使用的类型如下表所示:

    类型数字备注
    Double 1  
    String 2  
    Object 3  
    Array 4  
    Binary data 5  
    Undefined 6 已废弃。
    Object id 7  
    Boolean 8  
    Date 9  
    Null 10  
    Regular Expression 11  
    JavaScript 13  
    Symbol 14  
    JavaScript (with scope) 15  
    32-bit integer 16  
    Timestamp 17  
    64-bit integer 18  
    Min key 255 Query with -1.
    Max key 127  

    实例

    获取 "teacher" 集合中 title 为 String 的数据

    db.getCollection("teacher").find(
    {
    "like":{
    $type:'string'
    }
    }
    )

    需要注意的点

    • 注意域需要用""引起来

    • 注意$type类型后的数据类型需要小写'string'不是'String'

    It's a lonely road!!!
  • 相关阅读:
    Spark基础
    flink杂记
    算法
    算法小结
    Java内存模型
    LeetCode---Backtracking && DP
    LeetCode---Sort && Segment Tree && Greedy
    LeetCode---Depth-first && Breadth-first
    LeetCode---Bit Manipulation && Design
    MD5
  • 原文地址:https://www.cnblogs.com/JunkingBoy/p/14955955.html
Copyright © 2011-2022 走看看