当前位置:网站首页>[mongodb] basic use of mongodb database, special cases, and the installation and creation process of mongoose (including the installation of mongoose fixed version)
[mongodb] basic use of mongodb database, special cases, and the installation and creation process of mongoose (including the installation of mongoose fixed version)
2022-07-28 23:08:00 【Little wangbaoyou】
MongoDB The comparison operator for
- KaTeX parse error: Expected '}', got 'EOF' at end of input: …tion.find({ Elements :{ lt: The number }})
- KaTeX parse error: Expected '}', got 'EOF' at end of input: …tion.find({ Elements :{ gt : The number }})
- KaTeX parse error: Expected '}', got 'EOF' at end of input: …tion.find({ Elements :{ gte: The number }})
- KaTeX parse error: Expected '}', got 'EOF' at end of input: …tion.find({ Elements :{ lte: The number }})
- KaTeX parse error: Expected '}', got 'EOF' at end of input: …tion.find({ Elements :{ ne: The number }})
- Interval judgment ( Multiple conditions can be passed in )
- db.collection.find({ Elements :{ g t : The number 1 , gt: The number 1, gt: The number 1,lt: The number 2}})
- Indicates greater than the value 1 And smaller than the array 2
- Multi condition interval judgment
- db.collection.find({$or:[{ Elements : data 1},{ Elements : data 2},…]})
- Indicates that the judgment element meets the data 1 Or meet the data 2 The situation of
MongoDB View fixed data
When use ,- Never carry out without conditions - Query for
Before viewing the collection 10 Data
- db.collection.find().limit(10);
see 11-20 Data
- skip() Data used to skip a fixed number of entries
- db.collection.find().skip(10).limit(10);
Paging fixed formula
- skip(( Page number -1)* Fixed number of entries per page ).limit( Fixed number of entries per page );
Be careful :
- MongoDB Will automatically adjust skip and limit The order of
MongoDB Find special situations
- In direct use find() Method returns an array , Unable to get the value you need to find , You can use [0] or findOne() Method to find
- When the codes with the same meaning in two sets are inconsistent ( It is difficult to find when there are many data attributes , So try to make the code consistent when creating the set ), Create a variable to receive the value , Use this variable when searching in another set
- When querying, if the data does not appear correctly , Check the data type of query criteria , The result may be abnormal due to inconsistent data types
- When you only want to find individual data when querying , You can set the projection of query results at the position of the second parameter ( When using projection 1 Presentation display ,0 Means not to show ,_id Default display )
- db.collection.find({},{ Elements 1:1, Elements 2:0,…})
MongoDB Modify the value ( Increase or decrease )
- $inc increase ( Reduce ) The number (increment)
- db.collection.updateMany({ Conditions },{$inc:{ Modify the content }})
MongoDB Sort the data
- MongoDB The default is to use _id Sort
- have access to sort() Method needs to pass an object to specify the collation of the document (1 Arrange... In ascending order ,-1 Represents a descending order ), You can also pass multiple objects
- db.collection.find().sort( Elements 1:1, Elements 2:-1,…);
- Use elements first 1 Sort in ascending order , When element 1 Phase at the same time , On the element 2 Sort in descending order
Mongoose
- Use steps :
- Enter command in terminal npm i [email protected]( Version number )
- Linked database
- Create constraints Schema
- Create a module Model
Be careful
- limit() skip() sort() It can be written in any order
边栏推荐
- [radar] radar signal online sorting based on kernel clustering with matlab code
- TypeError: can‘t convert cuda:0 device type tensor to numpy. Use Tensor. cpu() to copy the tensor to
- HP ProLiant DL380 boot from USB flash drive, press which key
- (重要)初识C语言 -- 函数
- There are four ways for Nacos to configure hot updates and multiple ways to read project configuration files, @value, @refreshscope, @nacosconfigurationproperties
- MySQL常用的日期时间函数
- DirectX修复工具下载(exagear模拟器数据包在哪里)
- leetcode101. 对称二叉树
- 《MySQL数据库进阶实战》读后感(SQL 小虚竹)
- One of the experience of solving problems with code error reporting: CUDA does not match pytorch
猜你喜欢
![[physical application] atmospheric absorption loss with matlab code](/img/72/e6ac23012a59ac48a37bcbb068890b.png)
[physical application] atmospheric absorption loss with matlab code

After reading MySQL database advanced practice (SQL xiaoxuzhu)

The tenth improvement of yolov5: the loss function is improved to Siou

cnpm安装步骤

NPM run dev, automatically open the browser after running the project

can‘t convert cuda:0 device type tensor to numpy. Use Tensor. cpu() to copy the tensor to host memory

定了!哪吒S全系产品将于7月31日上市发售

Introduction to address book export without code development platform

18张图,直观理解神经网络、流形和拓扑

MySQL数据库的基本概念以及MySQL8.0版本的部署(一)
随机推荐
弹框遮罩层「建议收藏」
无代码开发平台通讯录入门教程
轮子七:TCP客户端
Servlet的使用手把手教学(一)
18 diagrams, intuitive understanding of neural networks, manifolds and topologies
Yolov5 improvement 7: loss function improvement
MySQL foundation - advanced functions
《MySQL数据库进阶实战》读后感(SQL 小虚竹)
[image segmentation] vein segmentation based on directional valley detection with matlab code
After reading MySQL database advanced practice (SQL xiaoxuzhu)
【雷达】基于核聚类实现雷达信号在线分选附matlab代码
[physical application] atmospheric absorption loss with matlab code
c语言进阶篇:指针(三)
Shell script foundation - shell operation principle + variable and array definitions
In 2020, the top ten domestic IC design enterprises will be exposed! These five industrial challenges still need to be overcome!
Improvement 18 of yolov5: the loss function is improved to alpha IOU loss function
Symbol symbol type
《Shortening passengers’ travel time A dynamic metro train scheduling approach using deep reinforcem》
DIP-VBTV: Color Image Restoration Model Combining Deep Image Prior and Vector Bundle Total Variation
leetcode101. 对称二叉树