Unrecognized expression '$toInt'

95 views
Skip to first unread message

harsh sharma

unread,
May 24, 2019, 4:16:15 AM5/24/19
to mongodb-user
whenever i am trying to convert string into integer i am getting this error


here is my queries

idconversion={$addFields:{convertedid:{$toInt:"$CustomerId"}} }
 db.orders_new.aggregate([idconversion])
using 3.4.20 version



Wan Bachtiar

unread,
May 27, 2019, 11:36:11 PM5/27/19
to mongodb-user

whenever i am trying to convert string into integer i am getting this error

Hi Harsh,

$toInt is available as a new operator from MongoDB v4.0+. It is a shorthand from operator $convert. $convert is part of a new feature in MongoDB v4.0 to enable the aggregation pipeline to transform mixed data types into standardised formats natively within the database.

See also MongoDB: Upgrade a Replica Set to 4.0

Regards,
Wan.

harsh sharma

unread,
May 29, 2019, 3:43:28 AM5/29/19
to mongodb-user
Thank you so much sir

cheers
Harsh
Reply all
Reply to author
Forward
0 new messages