Skip to content

Instantly share code, notes, and snippets.

@ritch
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ritch/10500272 to your computer and use it in GitHub Desktop.
Save ritch/10500272 to your computer and use it in GitHub Desktop.
From 0 to MongoDB in 30 seconds...
# 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