Database

[{"str":"123456"}]

Query

db.collection.aggregate([{$project:{newStr:{$substr:["$str",0,{$add:[{$strLenCP:"$str"},-2]}]}}}])

Result