updated sql queries to return only necessary columns

This commit is contained in:
bill bittner 2017-08-23 22:17:47 -07:00
parent fb900d40be
commit ab0e78d232

View file

@ -172,7 +172,7 @@ module.exports = {
}, },
getAllFreeClaims (name) { getAllFreeClaims (name) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
db.sequelize.query(`SELECT * FROM Claim WHERE name = '${name}' ORDER BY amount DESC, height ASC`, { type: db.sequelize.QueryTypes.SELECT }) db.sequelize.query(`SELECT name, claimId, outpoint, height, address FROM Claim WHERE name = '${name}' ORDER BY amount DESC, height ASC`, { type: db.sequelize.QueryTypes.SELECT })
.then(result => { .then(result => {
switch (result.length) { switch (result.length) {
case 0: case 0:
@ -188,7 +188,7 @@ module.exports = {
}, },
resolveAgainstClaimTable (name, claimId) { resolveAgainstClaimTable (name, claimId) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
db.sequelize.query(`SELECT * FROM Claim WHERE name = '${name}' AND claimId = '${claimId}'`, { type: db.sequelize.QueryTypes.SELECT }) db.sequelize.query(`SELECT name, claimId, outpoint, height, address, title, description FROM Claim WHERE name = '${name}' AND claimId = '${claimId}'`, { type: db.sequelize.QueryTypes.SELECT })
.then(result => { .then(result => {
switch (result.length) { switch (result.length) {
case 0: case 0:
@ -224,7 +224,7 @@ module.exports = {
getAllChannelClaims (channelId) { getAllChannelClaims (channelId) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
logger.debug(`finding all claims in channel "${channelId}"`); logger.debug(`finding all claims in channel "${channelId}"`);
db.sequelize.query(`SELECT * FROM Claim WHERE certificateId = '${channelId}' ORDeR BY height DESC;`, { type: db.sequelize.QueryTypes.SELECT }) db.sequelize.query(`SELECT name, claimId, outpoint, height, address FROM Claim WHERE certificateId = '${channelId}' ORDeR BY height DESC;`, { type: db.sequelize.QueryTypes.SELECT })
.then(result => { .then(result => {
switch (result.length) { switch (result.length) {
case 0: case 0: