postkrebs :/
This commit is contained in:
		@@ -39,24 +39,30 @@ const write = (kat, key, value, type, cb) => {
 | 
				
			|||||||
    value = JSON.stringify(value);
 | 
					    value = JSON.stringify(value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  console.log(kat, key, value, type);
 | 
					  console.log(kat, key, value, type);
 | 
				
			||||||
  sql.any("select * from cfg where class = ? && key = ? limit 1", [kat, key], (err, rows) => {
 | 
					  sql.any("select * from cfg where class = $1 && key = $2 limit 1", [kat, key]).then(rows => {
 | 
				
			||||||
    console.log(rows);
 | 
					 | 
				
			||||||
    if (rows.length > 0) {
 | 
					    if (rows.length > 0) {
 | 
				
			||||||
      sql.any("update cfg set value = ? where class = ? && key = ?", [value, kat, key], (err) => {
 | 
					      sql.any("update cfg set value = $1 where class = $2 && key = $3", [value, kat, key]).then(rows => {
 | 
				
			||||||
        console.log("updated", err);
 | 
					 | 
				
			||||||
        read().then(() => {
 | 
					        read().then(() => {
 | 
				
			||||||
          if(cb) cb();
 | 
					          if(cb) cb();
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					      .catch(err => {
 | 
				
			||||||
 | 
					        console.log("on update", err);
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else {
 | 
					    else {
 | 
				
			||||||
      sql.any("insert into cfg (class, key, value, type) values (?, ?, ?, ?)", [kat, key, value, type], (err) => {
 | 
					      sql.any("insert into cfg (class, key, value, type) values ($1, $2, $3, $4)", [kat, key, value, type]).then(rows => {
 | 
				
			||||||
        console.log("inserted", err);
 | 
					 | 
				
			||||||
        read().then(() => {
 | 
					        read().then(() => {
 | 
				
			||||||
          if (cb) cb();
 | 
					          if (cb) cb();
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					      .catch(err => {
 | 
				
			||||||
 | 
					        console.log("on insert", err);
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					  .then(err => {
 | 
				
			||||||
 | 
					    console.log("on select", err);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,8 +4,8 @@ let _query_get = `
 | 
				
			|||||||
  with ranked_quotes as (
 | 
					  with ranked_quotes as (
 | 
				
			||||||
    select nick,
 | 
					    select nick,
 | 
				
			||||||
      item,
 | 
					      item,
 | 
				
			||||||
      rank() over (partition by nick order by id),
 | 
					      rank() over (partition by lower(nick) order by id),
 | 
				
			||||||
      count(*) over (partition by nick) as total
 | 
					      count(*) over (partition by lower(nick)) as total
 | 
				
			||||||
    from nxy_quotes
 | 
					    from nxy_quotes
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
  select *
 | 
					  select *
 | 
				
			||||||
@@ -43,6 +43,7 @@ module.exports = bot => {
 | 
				
			|||||||
          sql.any(_query_add, [ nick, quote, `${e.network}.${e.channel}`, e.user.nick ])
 | 
					          sql.any(_query_add, [ nick, quote, `${e.network}.${e.channel}`, e.user.nick ])
 | 
				
			||||||
            .then(rows => { })
 | 
					            .then(rows => { })
 | 
				
			||||||
            .catch(err => {
 | 
					            .catch(err => {
 | 
				
			||||||
 | 
					              console.log(err);
 | 
				
			||||||
              e.reply("duplicate!");
 | 
					              e.reply("duplicate!");
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user