How to insert an 8-byte integer into MongoDB through JavaScript shell?


You can use below syntax for inserting an 8-byte integer in MongoDB through JavaScript shell −

anyVariableName= {"yourFieldName" : new NumberLong("yourValue")};

To display the above variable, you can use the variable name or printjson(). Following is the query to insert 8 byte integer in MongoDB −

> userDetail = {"userId" : new NumberLong("98686869")};
{ "userId" : NumberLong(98686869) }

Let us display the above variable value using variable name. The query is as follows −

> userDetail

This will produce the following output −

{ "userId" : NumberLong(98686869) }

Let us display the variable value using printjson() −

> printjson(userDetail);

This will produce the following output −

{ "userId" : NumberLong(98686869) }

Updated on: 30-Jul-2019

168 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements