// Init initializes connection to mongodb server
Init initializes connection to mongodb server
// Init initializes connection to mongodb server
func Init() (*mongo.Database, error) {
	val, exist := os.LookupEnv("DATABASE_URL")
	if !exist {
		return nil, errors.New("DATABASE_URL value not set")
	}
	db, exist := os.LookupEnv("DATABASE_NAME")
	if !exist {
		return nil, errors.New("DATABASE_NAME value not set")
	}
	client, err := mongo.Connect(context.Background(), options.Client().ApplyURI(val))
	if err != nil {
		return nil, err
	}
	return client.Database(db), nil
}
func Init ( ) ( * mongo . Database , error ) { val , exist := os . LookupEnv ( " " ) if ! exist { return nil , errors . New ( " " ) } db , exist := os . LookupEnv ( " " ) if ! exist { return nil , errors . New ( " " ) } client , err := mongo . Connect ( context . Background ( ) , options . Client ( ) . ApplyURI ( val ) ) if err != nil { return nil , err } return client . Database ( db ) , nil }
Init initializes connection to mongodb server
Init initializes connection to mongodb server