Last active
March 3, 2019 19:47
-
-
Save Hasstrup/54d6ef0a742f56f1c1b511c1eae510e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// assuming something we had a collection called movies and movies has two categories, action, comedy, | |
// and comedy has three sections (kevin hart, mike epps, chris rock) and action has three sections (chuck norris, jet li, jackie chan). | |
// if we were going to insert a document (movie) into the movies collection. | |
let movieOne = { _id: "Jolade's movie log", path: null } // the path null marks this as a root node | |
const m = db.movies.insert(movieOne) | |
//to declare a node to the category | |
const a = db.movies.insert({ path: `,${m._id},`, _id: "Jolade's movie log (action)" }) | |
// adding the path declares it as a subdocument of the the initial movie log | |
// to insert a new node into the action category | |
const c = db.movies.insert({ path: `,${m._id},${a._id},`, _id: 'Chuck Norris' }) | |
// to insert a leaf node into the chuck norris, sub_catetgory, | |
const leafMovie = db.movies.insert({ path: `,${m._id},${a._id},${c._id},` name: "Killer Cam by Chuck") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment