I am trying to convert a string to Decimal128 in NodeJs but I keep getting the following error “TypeError: Cannot read property ‘fromString’ of undefined”. Here is a snippet of my code.
Blockquote
const {MongoClient: mongodb} = require(“mongodb”);
const MongoClient = mongodb.MongoClient;
const Decimal128 = mongodb.Decimal128;
…
price: Decimal128.fromString(req.body.price.toString()), // store this as 128bit decimal in MongoDB