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