mongrel

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2022 License: MIT Imports: 11 Imported by: 0

README

mongrel

Mongo connect/disconnect package

Install

go get github.com/awkwardjake/mongrel

Docker Compose example

version: "3.9"

services:
  mongo:
    image: mongo
    restart: always
    ports:
      - "27017:27017"
    environment:
      MONGO_INITDB_DATABASE: exampleDB
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: rootPass
    volumes:
      - ./scripts/userScript.js:/docker-entrypoint-initdb.d/user.js:ro
      - mongodb_data_container:/usr/apps/exampleDB/database/mongo/db

volumes:
  mongodb_data_container:
user javascript
db.createUser(
    {
        user:"appUser",
        pwd:"appUserPass",
        roles: 
        [
            {
                role: "readWrite", 
                db: "exampleDB"
            }
        ]
    }
)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoConnectDetails

type MongoConnectDetails struct {
	Username   string `json:"username"`
	Password   string `json:"password"`
	Host       string `json:"host"`
	Port       int    `json:"port"`
	AuthSource string `json:"authSource"`
	App        string `json:"app"`
	// contains filtered or unexported fields
}

MongoConnectDetails model

func (*MongoConnectDetails) AssignCollection

func (mongoConnectDetails *MongoConnectDetails) AssignCollection(dbName string, collectionName string)

func (*MongoConnectDetails) Connect

func (mongoConnectDetails *MongoConnectDetails) Connect() error

Connect function to mongo that accepts MongoConnectDetails struct

func (*MongoConnectDetails) CreateDocument

func (mongoConnectDetails *MongoConnectDetails) CreateDocument(document *interface{}) (interface{}, error)

CreateDocument

func (*MongoConnectDetails) Disconnect

func (mongoConnectDetails *MongoConnectDetails) Disconnect() error

func (*MongoConnectDetails) GetDocument

func (mongoConnectDetails *MongoConnectDetails) GetDocument(documnetID string, model *interface{}) (*interface{}, error)

GetDocument will retrieve a single experience post by its uuid

func (*MongoConnectDetails) ListDatabases

func (mongoConnectDetails *MongoConnectDetails) ListDatabases() ([]string, error)

ListDatabases returns database list

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL