There are two chat rooms and each one is having two owners which are user object IDs. i would like to concatinate both the owners into one array so that i can find details of owners other than current user
[ { owners: [ 5d6caefdbb6f2921f45caf1d, 5d6caee9bb6f2921f45caf1b ],
_id: 5d6ccf5d55b38522a042dbb2,
createdAt: 2019-09-02T08:14:21.734Z,
updatedAt: 2019-09-02T08:14:21.734Z,
__v: 0,
id: '5d6ccf5d55b38522a042dbb2' },
{ owners: [ 5d6dfcd6e3b11807944348b8, 5d6caefdbb6f2921f45caf1d ],
_id: 5d6dfd48e3b11807944348ba,
createdAt: 2019-09-03T05:42:32.572Z,
updatedAt: 2019-09-03T05:42:32.572Z,
__v: 0,
id: '5d6dfd48e3b11807944348ba' } ]
const chatrooms = await ChatRoom.find({owners:{$all:[user._id]}})
//the above code was run to get result in problem statement
const owners = []
chatrooms.forEach((chatroom) => {
owners.push(chatroom.owners)
})
i am expecting something like this
owners= [ 5d6caefdbb6f2921f45caf1d, 5d6caee9bb6f2921f45caf1b,
5d6dfcd6e3b11807944348b8, 5d6caefdbb6f2921f45caf1d]