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

MongoDBDatabaseBig Data AnalyticsJavascript

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) }
raja
Published on 23-May-2019 08:00:15
Advertisements