Convert NumberLong to String in MongoDB



In order to convert NumberLong to String in MongoDB, you can use toString() −

NumberLong('yourValue').valueOf().toString();

To convert NumberLong to String, you can use valueOf() as well −

NumberLong('yourValue').valueOf();

Let us implement both the above syntaxes.

Following is the query to convert NumberLong to String with toString() −

> NumberLong('1000').valueOf().toString();

This will produce the following output −

1000

Following is the query to convert NumberLong to Number with valueOf()

> NumberLong('1000').valueOf();

This will produce the following output −

1000
Updated on: 2019-07-30T22:30:26+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements