$db = $this->getDatabase();
$query = 'SELECT giant_field, COUNT(field) AS counter
FROM massive_table mt
LEFT JOIN even_bigger_table ebt ON mt.field1 = ebt.field2
WHERE ebt.field3 = \'Zosia\'
ORDER BY mt.date DESC
HAVING counter > 1000';
$result = $db->query($query)->fetchAll();
Process
request
Query
Database
Fetching
Result
Process
Response
Send
Response
Process
request
Query
Database
Fetching
Result
Process
Response
Send
Response
? ? ? ? ? ?
var mysql = require('mysql');
var db = mysql.connection('user:pass@localhost:3306/nodetest1');
var sql = 'SELECT giant_field, COUNT(field) AS counter
FROM massive_table mt
LEFT JOIN even_bigger_table ebt ON mt.field1 = ebt.field2
WHERE ebt.field3 = \'Zosia\'
ORDER BY mt.date DESC
HAVING counter > 1000';
db.query(sql, function(data) {
response.setData(data);
response.send();
}
app.get('/user/:userId', function(req, res, next) {
db.get('users', userId, function(err, user) {
/** code **/
callbackCounter++;
locals.user = user;
if (callbackCounter == 2) {
res.render('user-profile', locals);
}
});
db.query('posts', {userId: userId}, function(err, posts) {
/** code **/
locals.posts = posts;
callbackCounter++;
if (callbackCounter == 2) {
res.render('user-profile', locals);
}
});
});
app.get('/user/:userId', function(req, res, next) {
async.parallel([
function(callback) {
db.get('users', userId, function(err, user) {
locals.user = user;
callback();
});
},
function(callback) {
db.query('posts', {userId: userId}, function(err, posts) {
locals.posts = posts;
callback();
});
}
], function(err) {
if (err) return next(err);
res.render('user-profile', locals);
});
});
Source: jsconf.eu/2014
careers.stackoverflow.com
http://adambard.com/blog/top-github-languages-2014/
https://www.paypal-engineering.com/2013/11/22/node-js-at-paypal/
https://www.paypal-engineering.com/2013/11/22/node-js-at-paypal/
https://www.paypal-engineering.com/2013/11/22/node-js-at-paypal/
https://engineering.groupon.com/2014/misc/shopping-cart/
http://thechangelog.com/116/
http://www.joyent.com/blog/walmart-node-js-memory-leak
import ( "io/db", "fmt", "http" )
func main() {
err, user := db.get('users', userId)
err, posts := db.query('posts',
fmt.Concat('user_id = ',userId)
)
http.response := render(user, posts)
http.send()
http.close()
}