当前位置:网站首页>Mongodb - use $type to query whether the type of a field is XXX
Mongodb - use $type to query whether the type of a field is XXX
2022-07-26 11:27:00 【Growth path of Xiaobo test】
A friend asked me why I have been updating recently mongodb Related operation tutorials ? Because , I need it in my current job .
My current main work will involve data validation after data cleaning , Generally, it is warehoused to mongodb In the library , To master skillfully mongodb Some usage words of , It can help you quickly find out whether there is abnormal data , Check the quality of data from all aspects .
such as : The product documentation states that a field should be of numeric type , Then you can write a query statement to reverse query whether there is data that does not meet the requirements .
Next , Learning today mongodb in $type Usage of :
Inquire about user In the table age Field is string Data of type :
db.getCollection("user").find({age:{$type:"string"}})
db.getCollection("user").find({age:{$type:2}})
mongo The common types in and the mapping table corresponding to the number relationship that can be used in query statements are as follows :

The above is just some common enumeration values enumerated by others , It may be updated later , In use , If you enter the wrong type to query , The query will report an error . At present, I only come into contact with numbers in my work 、 character string 、ObjectId、 Array 、Null type , I don't know what other types are at present , You can make a detailed introduction after you get in touch with it in the future .
Previous recommendation
MongoDB-MongoDB brief introduction
MongoDB- stay windows Install one locally on the computer mongodb The database of
MongoDB- adopt docker Set up a practice mongodb database
MongoDB- Use mongo/mongosh Command line connection to database
MongoDB- Quick start MongoDB Some simple operations on the command line
MongoDB-_id Introduction to the meaning of fields
MongoDB- insert data insert、insertOne、insertMany、save Usage introduction
MongoDB- Introduction to the basic usage of table data query
MongoDB- In the query statement >、>=、<、<=、=、!=、in、not in Usage introduction
MongoDB- Logical operators in query statements not、and、or、nor Usage introduction
MongoDB- In the query statement $exists And the combination of $ne、$nin、$nor、$not Introduction
边栏推荐
- [reprint] the multivariate normal distribution
- 记录个人遇到的错误
- 十年架构五年生活-06 离职的冲动
- [vscode] how to connect to the server remotely
- Getting started step by step using g2o to solve ICP problems - estimating the transformation relationship between two sets of 3D point sets with matching relationship
- A method to deal with the crash of C Halcon user control
- pytest fixture装饰器
- pytest 用例执行顺序
- Scrapy shell出现的一个错误
- 复现php一句话木马
猜你喜欢

Getting started step by step using g2o to solve ICP problems - estimating the transformation relationship between two sets of 3D point sets with matching relationship

postman 导出导入
![[vscode]如何远程连接服务器](/img/b4/9a80ad995bd589596d8b064215b55a.png)
[vscode]如何远程连接服务器

easyui03

DP的基本递归方程

easyui02

easyui05

Connection between PLC and servo motor

3dunity game project practice - first person shooting game

Pytest case execution sequence
随机推荐
线程之间的几种通信方式
由浅入深搭建神经网络
加载ORB词典
二分模板总结
Interview knowledge points
剑指 Offer 25. 合并两个排序的链表
SCADA and three industrial control systems PLC, DCS and FCS
Real time streaming protocol --rtsp
MongoDB-使用$type查询某个字段的类型是否为xxx
Toolstrip border removal
pytest 执行规则_基本用法_常用插件_常用断言_常用参数
Logging advanced use
想让照片中的云飘起来?视频编辑服务一键动效3步就能实现
像素和内存的关系
mysql学习笔记
Cmake常用命令总结
ISO 639:1988 : Code for the representation of names of languages
静态路由和动态路由
[development tool] ieda red
3Dunity游戏项目实战——第一人称射击游戏