I have to return the email if the user\_id from two different sources of data matches then it has to return the only email from the first source.
the first source is from the table results from PostgreSQL and the second source is from the JSON data.

I have tried this piece of code: 

```
var table = db.query(select * from users); //it has 4 fields _id, name, email, phoneNumber
jsondata.map(function(item){
var value = table.rows.filter(function(x) {
    if(x._id === item.user_id) {
        return x.email
    }
});

```

});

JSON Data: I have added only 2 data here for example but I have more than 1000 data. that is item 

```
{
    "_id": "5b56d462c53eb904fcb5a8fc",
    "user_id": 2,
    "date": "2017-08-29T08:22:00.000Z",
    "message": "jfgdshfgdfhgdshg"    
},
{
    "_id": "5b56d462c53eb904fcb5a8fc",
    "user_id": 44,
    "date": "2017-08-28T08:22:00.000Z",
    "message": "jfgdshfgdfhgdshg" 
}

```

Postgresql i.e x

```
_id | name | email       | phoneNumber|
---------------------------------------
 2  |  aa  |aa@gmail.com | 98998998   |
 3  |  bb  |bb@gmail.com | 09887665   |
 44 |  cc  |cc@gmail.com | 98765655   |

```