- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between NumberLong(x) and NumberLong(“x”) in MongoDB?
The NumberLong(x) goes beyond its limit value and round off the value whereas NumberLong(“x”) does not.
Now, we will consider a number and would use it for both NumberLong(x) and NumberLong(“x”) to see the difference.
Let us create a collection with documents −
> db.demo603.insert({"longValue" : NumberLong(988998985857575789)}); WriteResult({ "nInserted" : 1 }) > db.demo603.insert({"longValueInString" : NumberLong("988998985857575789")});
Display all documents from a collection with the help of find() method −
> db.demo603.find().pretty();
This will produce the following output −
{ "_id" : ObjectId("5e9605e5ed011c280a0905d1"), "longValue" : NumberLong("988998985857575808") } { "_id" : ObjectId("5e9605faed011c280a0905d2"), "longValueInString" : NumberLong("988998985857575789") }
Advertisements