Created
December 13, 2017 15:31
-
-
Save TheRadioGuy/997e405dfd5dd943f49488de733b94c5 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
| var getMessages = async function(login, loginMy){ | |
| if(isEmpty(login) || isEmpty(loginMy)){ | |
| return(u(ERROR_PARAMS_EMPTY_CODE, 'Some params is empty', true)); | |
| return false; | |
| } | |
| var 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"); | |
| var messagesOne=[]; | |
| async.forEachOf(resp, function (value, key, callback) { | |
| value['from'] = value['fromU']; | |
| value['to'] = value['toU']; | |
| value['fromU']=undefined; | |
| value['toU']=undefined; | |
| messagesOne.push(value); | |
| callback(); | |
| }, function (err) { | |
| if (err) console.error(err.message); | |
| // configs is now a map of JSON data | |
| console.log('return!'); | |
| return(u(SUCCESSFUL_GET_MESSAGES, messagesOne, false)); | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment