goodm

package module
v0.0.0-...-2566dca Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 14 Imported by: 0

README

goodm

go mongo object data modeling

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateContext

func CreateContext() (context.Context, context.CancelFunc, error)

func GetCollectionName

func GetCollectionName(obj DataObject) string

func Init

func Init(c Config) error

func Ping

func Ping() error

Types

type BaseObject

type BaseObject struct {
	Id           primitive.ObjectID `bson:"_id,omitempty"`
	CreationTime time.Time          `bson:"_creation_date"`
	UpdateTime   time.Time          `bson:"_update_time"`
	TypeName     string             `bson:"_type_name"`
}

type Collection

type Collection interface {
	Save(obj interface{}) error
	Update(obj interface{}, filter interface{}) error
	UpdateAll(obj interface{}, filter interface{}) (int, error)
	Load(obj interface{}) error
	Find(obj interface{}, filter interface{}) error
	FindSpecificType(obj interface{}, filter interface{}) error
	Drop()
	Delete(obj interface{}) error
	Count(filter interface{}) (int64, error)
	MongoCollection() *mongo.Collection
	CreateIndex(name string, keys interface{}) error
}

func Coll

func Coll(o interface{}) Collection

type CollectionStruct

type CollectionStruct struct {
	Collection *mongo.Collection
}

func (CollectionStruct) Count

func (coll CollectionStruct) Count(filter interface{}) (int64, error)

func (CollectionStruct) CreateIndex

func (coll CollectionStruct) CreateIndex(name string, keys interface{}) error

func (CollectionStruct) Delete

func (coll CollectionStruct) Delete(o interface{}) error

func (CollectionStruct) Drop

func (coll CollectionStruct) Drop()

func (CollectionStruct) Find

func (coll CollectionStruct) Find(o interface{}, filter interface{}) error

func (CollectionStruct) FindSpecificType

func (coll CollectionStruct) FindSpecificType(o interface{}, filter interface{}) error

func (CollectionStruct) Load

func (coll CollectionStruct) Load(o interface{}) error

func (CollectionStruct) MongoCollection

func (coll CollectionStruct) MongoCollection() *mongo.Collection

func (CollectionStruct) Save

func (coll CollectionStruct) Save(o interface{}) error

func (CollectionStruct) Update

func (coll CollectionStruct) Update(o interface{}, filter interface{}) error

func (CollectionStruct) UpdateAll

func (coll CollectionStruct) UpdateAll(o interface{}, filter interface{}) (int, error)

type Config

type Config struct {
	ConnectionString string
	// contains filtered or unexported fields
}

type DataObject

type DataObject struct {
	// contains filtered or unexported fields
}

func Obj

func Obj(obj interface{}) DataObject

func (DataObject) Append

func (obj DataObject) Append(val DataObject)

func (DataObject) Clear

func (obj DataObject) Clear()

func (DataObject) CreateNew

func (obj DataObject) CreateNew() DataObject

func (DataObject) Field

func (obj DataObject) Field(name string) DataObject

func (DataObject) FieldExists

func (obj DataObject) FieldExists(name string) bool

func (DataObject) FieldTag

func (obj DataObject) FieldTag(name string, tagName string) string

func (DataObject) FullTypeName

func (obj DataObject) FullTypeName() string

func (DataObject) GetID

func (obj DataObject) GetID() (primitive.ObjectID, error)

func (DataObject) Index

func (obj DataObject) Index(i int) DataObject

func (DataObject) Interface

func (obj DataObject) Interface() interface{}

func (DataObject) IsSlice

func (obj DataObject) IsSlice() bool

func (DataObject) Len

func (obj DataObject) Len() int

func (DataObject) Name

func (obj DataObject) Name() string

func (DataObject) Package

func (obj DataObject) Package() string

func (DataObject) Set

func (obj DataObject) Set(val interface{})

func (DataObject) SetCreationTime

func (obj DataObject) SetCreationTime() error

func (DataObject) SetID

func (obj DataObject) SetID(id primitive.ObjectID) error

func (DataObject) SetTypeName

func (obj DataObject) SetTypeName() error

func (DataObject) SetUpdateTime

func (obj DataObject) SetUpdateTime() error

func (DataObject) String

func (obj DataObject) String() string

Jump to

Keyboard shortcuts

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