package fiko_mongo

import (
	"context"
	"time"

	"github.com/gofiber/fiber/v2"
	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/mongo"
	"go.mongodb.org/mongo-driver/mongo/options"
)

func Init(app *fiber.App) {

	databaseURL := "mongodb://127.0.0.1:8001/"
	ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
	client, _ := mongo.Connect(ctx, options.Client().ApplyURI(databaseURL).SetCompressors([]string{"zstd"}))

	//kisiler := client.Database("fikoyt").Collection("hareketler")
	result, err := client.Database("fikoyt").Collection("hareketler").Find(ctx, bson.M{}, options.Find().SetLimit(10))
	print(result)

	app.Get(
		`/fikomongo`,
		func(c *fiber.Ctx) error {
			return c.Status(200).JSON(err)
		},
	)
}
