Question, I'm just wondering if I can call a mongoose schema inside the socket.on function? Like
socket.on('sendMessage', ({ senderId, receiverId, message }) => {
const user = getUser(receiverId);
const accountId = await accountModel.findById(senderId);
if (user) {
socket.to(user.socketId).emit('getMessage', {
accountId,
message,
});
}
});
Thanks!