suppose there is a table Group User, and the owner of Group is associated with User
Group
_ id
name
owner: {type: Schema.ObjectId, ref: "User"}
User
_ id
name
Q: search to find the Group list, fuzzy search according to Group name and User name, and have the paging form of count?
< hr >if the condition is only Group name, I will write
var reg = new RegExp(searchText, i);
var q = {name: {$regex: reg}};
Group.count(q, function(err, count){
Group.find(q).skip(skip).limit(limit).exec(function(err, groups){
return res.status(200).json({
count: count,
groups: groups
})
})
})