Created
August 2, 2013 13:58
-
-
Save adrianmilne/6140092 to your computer and use it in GitHub Desktop.
Example MongoDB Build Script for a simple Library Database
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
print("Starting MongoDB Library Database Build Script") | |
print("Creating Libary Database") | |
var libraryDB = db.getSiblingDB("library") | |
print("Creating Book Collection") | |
libraryDB.createCollection("book") | |
print("Creating index on 'type' field") | |
libraryDB.book.ensureIndex({type:1}) | |
print("Populating Book Data") | |
libraryDB.book.insert({name:"The Lord Of The Rings",author:"J.R.R. Tolkien",type:"Fantasy"}) | |
libraryDB.book.insert({name:"The Silmarillion",author:"JRR Tolkien",type:"Fantasy"}) | |
libraryDB.book.insert({name:"Dune",author:"Frank Herbert",type:"Sci-Fi"}) | |
print("Finished MongoDB Library Database Build Script") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment