Displaying Mongo 3.4 decimal type in Blaze

Hi folks,

I’ve followed @robfallows advice for running Mongo 3.4 locally to use Mongo’s new NumberDecimal type. The only problem now is displaying these fields in a Blaze template. Has anyone successfully done this?

Here’s how it’s stored in my collection:

"contactScore" : NumberDecimal("0.1230739")

When I try to display this field in my template though, the browser console shows it as appearing as:

Object
_bsontype: "Decimal128"
bytes: Uint8Array[16]
__proto__: Object

I’ve tried various suggestions to decode the Uint8Array and am in the progress of testing the MongoDB Extended JSON npm package, but can’t get anything to give me back a string, much less a number. Any advice from someone else who has dealt with this?

Thanks!

Update

After installing and testing the MongoDB Extended JSON package from npm, the output from EJSON.stringify() is {"$numberDecimal":"[object Object]"}. Not sure what I’m doing wrong, would love some feedback. Thanks!

What are the contents of that bytes array? You said it won’t give you back a string or a number; do you mean it doesn’t give ANY strings or numbers? Or do you mean it won’t give you the CORRECT string or number? I guess you’ve already tried doing a for loop to console.log the contents?

It’s good that MongoDB introduced this decimal type. Is or will there be support in Meteor for it?

Any news on this topic ?

Looks like it’s ready to merge:

2 Likes