Ранее на php я использовал mysqli_fetch_arrayС вашим запросом и на PHP вернётся одна строка.
const mysql = require('mysql2/promise');
const conn = await mysql.createConnection({ ... });
const logins = ['marikas', 'tym', 'bars'];
async function main() {
const result = await conn.execute(
'SELECT login, cash FROM clients WHERE login in (?)',
[logins],
);
for ([login, cash] of result) {
console.log(login, cash);
}
}
const mysql = require('mysql2');
const conn = mysql.createConnection({ ... });
const logins = ['marikas', 'tym', 'bars'];
function main() {
conn.execute(
'SELECT login, cash FROM clients WHERE login in (?)',
[logins],
(err, result) => {
if (err) {
throw new Error(err);
}
for ([login, cash] of result) {
console.log(login, cash);
}
},
);
}
countCookies(3, 6, [0, 0, 0]); // 1
countCookies(3, 2, [0, 2, 2]); // 0
- const allCookies = cookies.reduce((sum, acc) => sum + acc, 0);
- let maxCookies = Number(Math.max.apply(null, cookies));
+ const maxCookies = Math.max(...cookies);
- let sum = cookies.reduce((acc, c) => acc + Math.floor((c + K - 1) / K), 0);
+ const sum = cookies.reduce((acc, c) => acc + Math.ceil(c / K), 0);
oldArray.sort((a, b) => a.id - b.id);
newArray.sort((a, b) => a.id - b.id);
oldIdx = 0;
newIdx = 0;
while (oldIdx < oldArray.length || newIdx < newArray.length) {
if (oldIdx >= oldArray.length || oldArray[oldIdx].id > newArray[newIdx].id) {
console.log(`Added id newArray[newIdx].id`);
newIdx += 1;
continue;
}
if (newIdx >= newArray.length || oldArray[oldIdx].id < newArray[newIdx].id) {
console.log(`Deleted id oldArray[oldIdx].id`);
oldIdx += 1;
continue;
}
if (oldArray[oldIdx].x !== newArray[newIdx].x) {
console.log(`Changed id newArray[newIdx].id`);
oldIdx += 1;
newIdx += 1;
}
}
telegramBot.sendInvoice(
chatId,
title,
description,
payload,
providerToken,
currency,
prices,
[options]
)