showing results for - "working with bson in javascript"
Giulio
23 Jan 2020
1/*
2    This code comes from Vincent Lab
3    And it has a video version linked here: https://www.youtube.com/watch?v=6pBWBNxzCUk
4*/
5
6// Import dependencies
7const fs = require("fs");
8const BSON = require("bson");
9
10// Serialize a document
11const data = BSON.serialize({ name: "Bob" });
12fs.writeFileSync("data.bson", data);
13console.log(data);
14
15// Deserialize the resulting Buffer
16const doc = BSON.deserialize(data);
17console.log(doc);