mongodb_adapter

package module
v0.0.0-...-5d7e299 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: MIT Imports: 7 Imported by: 0

README

MongoDB Adapter for Go

This module help to you some mongo command which add, get and del

Connect to Redis
mongoClient = ConnectMongo("mongodb://localhost:23176", , "dbname", "CollectionName")
Find
err := mongoClient.GetData(bson.D{{filters}}, interface{})

if err != nil {
    log.Fatal(err.Error())
}
All Rows
err := mongoClient.GetAll(bson.D{{filters}}, interface{})

if err != nil {
    log.Fatal(err.Error())
}
Insert
err := mongoClient.GetAll(bson.D{{filters}}, interface{})

if err != nil {
    log.Fatal(err.Error())
}
Update
err := mongoClient.GetAll(bson.D{{filters}}, bson.D{{filters}})

if err != nil {
    log.Fatal(err.Error())
}
Delete
err := mongoClient.DeleteData(bson.D{{filters}})

if err != nil {
    log.Fatal(err.Error())
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoClient

type MongoClient struct {
	Client     *mongo.Client
	Collection *mongo.Collection
}

func ConnectMongo

func ConnectMongo(mongoUrl string, dbName, collectionName string) *MongoClient

func (*MongoClient) AddData

func (c *MongoClient) AddData(insert interface{}) error

func (*MongoClient) DeleteData

func (c *MongoClient) DeleteData(filter bson.D) error

func (*MongoClient) GetAll

func (c *MongoClient) GetAll(filter bson.D, returnData interface{}) error

func (*MongoClient) GetData

func (c *MongoClient) GetData(filter bson.D, returnData interface{}) error

func (*MongoClient) UpdateData

func (c *MongoClient) UpdateData(filter bson.D, update bson.D) error

Jump to

Keyboard shortcuts

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