Last active
August 29, 2015 13:59
-
-
Save ritch/10500272 to your computer and use it in GitHub Desktop.
From 0 to MongoDB in 30 seconds...
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
# Run the following steps in your terminal... | |
# make sure you have node and mongo installed | |
npm install strong-cli | |
# create a loopback project | |
slc lb project mongo-example | |
cd mongo-example | |
# create a loopback model | |
slc lb model todo | |
# tell loopback you want to use mongodb | |
# add the following to datasources.json | |
... | |
"db": { | |
"connector": "mongodb", | |
"url": "mongodb://localhost:27015" | |
} | |
... | |
# hit mongodb from node | |
# add this to app.js | |
var Todo = app.models.todo; | |
Todo.create({ | |
title: 'install loopback and connect to mongodb', | |
done: true | |
}); | |
# start the app in the background | |
node app & | |
# hit mongodb over REST | |
curl localhost:3000/api/todos | |
[{"id": 1, "title": "install loopback and connect to mongodb", "done": true}] | |
# learn more here | |
open http://loopback.io |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment