Skip to content

📝 [Proposal]: Add template for a database connection based on user input #3

@tuhinexe

Description

@tuhinexe

Feature Proposal Description

It would be very helpful if there was an option to choose from an SQL DB and a NoSQL DB. ( PostgreSQL, MongoDB )

  • There should be templates for the mentioned DB connection configs.
  • Based on user selection the internal/config will contain a ConnectDB function to connect with Database,
  • localhost of the respective DB will be used for connection

Feature Examples

package main

import (
	"context"
	"log"

	"go.mongodb.org/mongo-driver/mongo"
	"go.mongodb.org/mongo-driver/mongo/options"
)

var collection *mongo.Collection
var ctx = context.TODO()

func init() {
	clientOptions := options.Client().ApplyURI("mongodb://localhost:27017/")
	client, err := mongo.Connect(ctx, clientOptions)
	if err != nil {
		log.Fatal(err)
	}

	err = client.Ping(ctx, nil)
	if err != nil {
		log.Fatal(err)
	}

        return client
}

Checklist:

  • I agree to follow Optical's Code of Conduct.
  • I have searched for existing issues that describe my proposal before opening this one.
  • I understand that a proposal that does not meet these guidelines may be closed without explanation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions