当前位置:网站首页>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
边栏推荐
猜你喜欢

Cmake常用命令总结

pytest conftest.py和fixture的配合使用

加载ORB词典

剑指 Offer 25. 合并两个排序的链表

MySQL locking mechanism

Pyqt5 rapid development and practice Chapter 1 understanding pyqt5

win10 1903 笔记本开热点出现蓝屏问题

Data visualization - White Snake 2: black snake robbery (2)

Real time streaming protocol --rtsp

Three properties of concurrency
随机推荐
win10 1903 笔记本开热点出现蓝屏问题
349. Intersection of two arrays
Connection between PLC and servo motor
记录个人遇到的错误
实时流式协议--RTSP
leetcode-209. 长度最小的子数组(二分、前缀和、滑动窗口)
The combination of pytest confitest.py and fixture
36.【const函数放在函数前后的区别】
easyui02
mysql数据库进阶
[学习进度]5月
新来个技术总监要我做一个 IP 属地功能~
[learning progress] may
Novice source code hashtable
logging基本使用
MySQL事务详解
Dichotomous template summary
想让照片中的云飘起来?视频编辑服务一键动效3步就能实现
Leetcode-209. subarray with the smallest length (binary, prefix and, sliding window)
easyui02