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);