rpaschoal / ng-chat

💬 A simple facebook/linkedin lookalike chat module for Angular applications.
MIT License
155 stars 92 forks source link

create friendlist using db query data #162

Closed fouzianigarsultana closed 4 years ago

fouzianigarsultana commented 4 years ago

Hello, I have tried ng-chat and am new in socket.io world. I am trying to create friendlist with specific user group whose data will render from database. But I am not abling.Would you please advice me my list is like this: `router.get("/chat", (req, res, next) => { ALUser.find({ $and: [{ uniname: { '$regex': req.query.uniname, '$options': 'i' } }, { dept: { '$regex': req.query.dept, '$options': 'i' } }, { session: { '$regex': req.query.session, '$options': 'i' } } ] }).then(data => { res.status(200).json({ message: "Users retrieved successfully!", alusers: data }); }); }); var usersCollection = []; app.post('/chat', function (req, res) { var clonedArray = usersCollection.slice();

// Getting the userId from the request body as this is just a demo // Ideally in a production application you would change this to a session value or something else var i = usersCollection.findIndex(x => x.participant.id == req.body.userId); clonedArray.splice(i, 1); res.json(clonedArray); });`