-
-
Save sergeysova/cd6f988d62af491d0ce6949fa4b562f4 to your computer and use it in GitHub Desktop.
NodeJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function getMessages(login, loginMy) { | |
| if (!login || !loginMy) { | |
| throw new TypeError('param login and loginMy should be present'); | |
| } | |
| const resp = await connection.query(`SELECT * FROM messages WHERE fromU = '${login}' AND toU = '${loginMy}' UNION SELECT * FROM messages WHERE fromU = '${loginMy}' AND toU = '${login}' ORDER BY date DESC`); | |
| return resp.map(value => Object.assign({ | |
| from: value.fromU, | |
| to: value.toU, | |
| }, value, { fromU: undefined, toU: undefined })) | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment