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);
});`
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); });`