1

I'm using node driver to add records to mongo. I have a collection where one of the fields is: { "$binary": "base64 enconded binary" }.

However a direct injection of the key starting with $ results in error: Error: key $binary must not start with '$'

Question: how to handle this situation? Is there a javascript function I should call that will be interpreted by mongo as BSON binray function (like with the ISODate() - new Date() and NumberLong() -> Long())? Thanks

1 Answer 1

1

I appears that I have missed the function Binary({buffer},{binary_type}). More on it: https://mongodb.github.io/node-mongodb-native/api-bson-generated/binary.html

My usage:

db.collection(coll).insert({
    "id" : rand1,
    "ReportData" : Binary("aaaaa", 0),
    ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.