func (r *UserRepository) FindByID(ctx context.Context, id string) (*flaggio.User, error) {
	span, ctx := opentracing.StartSpanFromContext(ctx, "MongoUserRepository.FindByID")
	defer span.Finish()
	filter := bson.M{"_id": id}
	var u userModel
	if err := r.col.FindOne(ctx, filter).Decode(&u); err != nil {
		if err == mongo.ErrNoDocuments {
			return nil, errors.NotFound("user")
		}
		return nil, err
	}
	u.Context = sanitizeUserContextPrefixKey(u.Context, "%", "$")
	return u.asUser(), nil
}
FindByID returns a user by its id.
package mongodb
import (
	"context"
	"regexp"
	"strings"
	"time"
	"github.com/opentracing/opentracing-go"
	"github.com/victorkt/flaggio/internal/errors"
	"github.com/victorkt/flaggio/internal/flaggio"
	"github.com/victorkt/flaggio/internal/repository"
	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/bson/primitive"
	"go.mongodb.org/mongo-driver/mongo"
	"go.mongodb.org/mongo-driver/mongo/options"
)
var _ repository.User = (*UserRepository)(nil)
type UserRepository struct {
	db  *mongo.Database
	col *mongo.Collection
}
func (r *UserRepository) FindAll(ctx context.Context, search *string, offset, limit *int64) (*flaggio.UserResults, error) {
	span, ctx := opentracing.StartSpanFromContext(ctx, "MongoUserRepository.FindAll")
	defer span.Finish()
	filter := bson.M{}
	if search != nil {
		filter["_id"] = primitive.Regex{Pattern: regexp.QuoteMeta(*search), Options: "i"}
	}
	cursor, err := r.col.Find(ctx, filter, &options.FindOptions{
		Skip:  offset,
		Limit: limit,
		Sort:  bson.M{"_id": 1},
	})
	if err != nil {
		return nil, err
	}
	var users []*flaggio.User
	for cursor.Next(ctx) {
		var u userModel
		if err := cursor.Decode(&u); err != nil {
			return nil, err
		}
		u.Context = sanitizeUserContextPrefixKey(u.Context, "%", "$")
		users = append(users, u.asUser())
	}
	if err := cursor.Err(); err != nil {
		return nil, err
	}
	total, err := r.col.CountDocuments(ctx, filter)
	if err != nil {
		return nil, err
	}
	return &flaggio.UserResults{
		Users: users,
		Total: int(total),
	}, nil
}