in source/services/vehicle/lib/anomaly.js [53:98]
anomaly.prototype.listAnomaliesByVehicle = function(ticket, vin, cb) {
// verify user owns vehicle
let params = {
TableName: ownerTable,
Key: {
owner_id: ticket['cognito:username'],
vin: vin
}
};
let docClient = new AWS.DynamoDB.DocumentClient(dynamoConfig);
docClient.get(params, function(err, data) {
if (err) {
console.log(err);
return cb(err, null);
}
if (!_.isEmpty(data)) {
var anomaly_params = {
TableName: ddbTable,
KeyConditionExpression: 'vin = :vin',
ExpressionAttributeValues: {
':vin': vin
}
};
let docClient = new AWS.DynamoDB.DocumentClient(dynamoConfig);
docClient.query(anomaly_params, function(err, anomaly_data) {
if (err) {
console.log(err);
return cb(err, null);
}
return cb(null, anomaly_data);
});
} else {
return cb({
error: {
message: 'The vehicle requested is not registered under the user.'
}
}, null);
}
});
};