larvituser
Advanced tools
Comparing version 0.0.1-beta to 0.0.2-beta
@@ -42,3 +42,2 @@ 'use strict'; | ||
exports.create = function create(username, password, fields, callback) { | ||
log.verbose('yyyyeahh'); | ||
checkDbStructure(function() { | ||
@@ -277,2 +276,38 @@ log.verbose('Trying to create user', {'username': username, 'fields': fields}); | ||
/** | ||
* Get field data for a user | ||
* | ||
* @param int userId | ||
* @param str fieldName | ||
* @param func callback(err, data) - data is always an array of data (or empty array) | ||
*/ | ||
exports.getFieldData = function getFieldData(userId, fieldName, callback) { | ||
exports.getFieldId(fieldName, function(err, fieldId) { | ||
if (err) { | ||
callback(err); | ||
return; | ||
} | ||
var sql = 'SELECT data FROM user_users_data WHERE user_id = ? AND field_id = ?', | ||
dbFields = [userId, fieldId]; | ||
db.query(sql, dbFields, function(err, rows) { | ||
if (err) { | ||
callback(err); | ||
return; | ||
} | ||
var data = [], | ||
rowNr = 0; | ||
while (rows[rowNr] !== undefined) { | ||
data.push(rows[rowNr].data); | ||
rowNr++; | ||
} | ||
callback(null, data); | ||
}); | ||
}); | ||
} | ||
/** | ||
* Get data field id by field name | ||
@@ -279,0 +314,0 @@ * |
@@ -30,5 +30,5 @@ { | ||
}, | ||
"version": "0.0.1beta", | ||
"version": "0.0.2beta", | ||
"readmeFilename": "README.md", | ||
"license": "MIT" | ||
} |
@@ -171,2 +171,12 @@ 'use strict'; | ||
}); | ||
it('should get field data from any user', function(done) { | ||
userLib.fromUsername('lilleman', function(err, user) { | ||
userLib.getFieldData(user.id, 'foo', function(err, data) { | ||
assert.deepEqual(data, ['bar']); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -173,0 +183,0 @@ |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
27504
867