Skip to content

Commit

Permalink
Mongodb init
Browse files Browse the repository at this point in the history
  • Loading branch information
lecaoquochung committed Jul 25, 2016
1 parent 83209cb commit fe60d93
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,21 @@ window.onload = function() {
### Define Controller
- path: frontend/js/controllers/Home.js
- ?: onrender, onconstruct, onteardown, onupdate http://docs.ractivejs.org/latest/options
- config gulp for automation ractive convert /frontend/tpl/*.html -> *.js (ractive & browserify)
- config gulp for automation ractive convert /frontend/tpl/.html -> .js (ractive & browserify)

### Define View
- Ractive component
- MVC actually are just a definition & need to follow some rules with it
- In this example, in the view template footer (make some data call from model like models/Version.js)

### Define Model
- Path: /frontend/js/models
- Path: /frontend/js/models
- Models share the same methods
- Specify the URL -> Base module take care of the rest

## MONGODB (MANAGING USER)
- Node.js works well with MongoDB (http://www.mongodb.org/).
```
brew install mongodb
npm install mongodb --save
```
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"gulp-rename": "^1.2.2",
"gulp-tap": "^0.1.3",
"gulp-uglify": "^1.5.4",
"mongodb": "^2.2.4",
"ractive": "^0.7.3",
"reactive": "^1.2.0"
},
Expand Down
16 changes: 16 additions & 0 deletions sample/mongodb/connect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// dbname: nodejs-example
// status: not work
var MongoClient = require('mongodb').MongoClient;
MongoClient.connect('mongodb://127.0.0.1:27017/nodejs-example',
function(err, db) {
// ...
});

// db object with CRUD
var collection = db.collection('users');
collection.insert({
name: 'Hung',
email: 'lehung@test.com'
}, function(err, result) {
// ...
});

0 comments on commit fe60d93

Please sign in to comment.