Answers for "Working with BSON in JavaScript"

1

Working with BSON in JavaScript

/*
    This code comes from Vincent Lab
    And it has a video version linked here: https://www.youtube.com/watch?v=6pBWBNxzCUk
*/

// Import dependencies
const fs = require("fs");
const BSON = require("bson");

// Serialize a document
const data = BSON.serialize({ name: "Bob" });
fs.writeFileSync("data.bson", data);
console.log(data);

// Deserialize the resulting Buffer
const doc = BSON.deserialize(data);
console.log(doc);
Posted by: Guest on April-20-2021

Code answers related to "Working with BSON in JavaScript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language