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

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 30-Jul-2019

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements