// FindUsersByUsernameOrEmail return a list of users searched by username or email
FindUsersByUsernameOrEmail return a list of users searched by username or email
// FindUsersByUsernameOrEmail return a list of users searched by username or email
func (ur *UserMongoRepository) FindUsersByUsernameOrEmail(q string, page int) []models.User {
	session, db := database.GetSessionAndDB(database.MONGO_DB)
	p := ".*" + q + ".*"
	query := bson.M{"$or": []bson.M{bson.M{"username": bson.RegEx{p, "i"}},
		bson.M{"email": bson.RegEx{p, "i"}}}}
	skips := PAGE_LENGTH * (page - 1)
	var users []models.User
	db.C(USERS_COLLECTION).Find(query).Select(bson.M{"password": 0}).Sort("username").Skip(skips).Limit(PAGE_LENGTH).All(&users)
	database.MongoDBPool.Close(session)
	return users
}
func ( ur * UserMongoRepository ) FindUsersByUsernameOrEmail ( q string , page int ) [ ] models . User { session , db := database . GetSessionAndDB ( database . MONGO_DB ) p := " " + q + " " query := bson . M { " " : [ ] bson . M { bson . M { " " : bson . RegEx { p , " " } } , bson . M { " " : bson . RegEx { p , " " } } } } skips := PAGE_LENGTH * ( page - 1 ) var users [ ] models . User db . C ( USERS_COLLECTION ) . Find ( query ) . Select ( bson . M { " " : 0 } ) . Sort ( " " ) . Skip ( skips ) . Limit ( PAGE_LENGTH ) . All ( & users ) database . MongoDBPool . Close ( session ) return users }
FindUsersByUsernameOrEmail return a list of users searched by username or email
FindUsersByUsernameOrEmail return a list of users searched by username or email