I use Sequelize, MySQL and Node to write a web application.
For most of my database needs, I usually do some checking, then retrieve my models (with impatience with the associations) and send them to the client, almost always as they are (at least so far).
I wrote a small utility function getValuesFromRowsto extract values ββfrom a returned array of strings:
getValuesFromRows: function(rows, valuesProp) {
valuesProp = valuesProp || 'values';
if (rows instanceof Array) {
var allValues = [];
for (var i = 0; i < rows.length; ++i) {
allValues[i] = rows[i][valuesProp];
}
return allValues;
}
else if (rows) {
return rows[valuesProp];
}
return null;
}
...findAll(...)...complete(function(err, rows) {
var allValues = getValuesFromRows(rows);
sendToClient(errToString(err, user), allValues);
});
. , . , values , , values () . Sequelize ( Sequelize), ?
" values Project values values Project.members" (). , , (, tasks tasks ..).
, ββ?