Skip to content
This repository has been archived by the owner on Jul 26, 2020. It is now read-only.

Commit

Permalink
Add support for MongoDB databases
Browse files Browse the repository at this point in the history
  • Loading branch information
beeman committed Oct 16, 2014
1 parent 88254ce commit 6b884e6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ It will open the project in your default browser with livereload enabled.
This will take care of reloading the page when you change your code.


## Connect to a database

You can specify the URL to the MongoDB database you want to use with the `MONGODB_URL` environment variable.

MONGODB_URL="mongodb://localhost:27017/loopback-angular-admin" npm start

Set `INITDB` to true if you want to load the initial dataset, which creates the admin user. The memory database (default) does this automatically.

INITDB=true MONGODB_URL="mongodb://localhost:27017/loopback-angular-admin" npm start


## Development

For development you'd want to look into [yeoman](http://yeoman.io).
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"loopback": "^2.5.0",
"loopback-boot": "^2.1.0",
"loopback-component-storage": "^1.0.5",
"loopback-connector-mongodb": "^1.4.4",
"serve-favicon": "^2.1.5"
},
"optionalDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion server/boot/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module.exports = function(app) {

if (app.dataSources.db.name !== 'Memory') {
if (app.dataSources.db.name !== 'Memory' && !process.env.INITDB) {
return;
}

Expand Down
11 changes: 11 additions & 0 deletions server/datasources.local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var MONGODB_URL = process.env.MONGODB_URL || null;

if(MONGODB_URL) {
module.exports = {
db: {
name: "db",
connector: "loopback-connector-mongodb",
url: MONGODB_URL
}
};
}

0 comments on commit 6b884e6

Please sign in to comment.