Documentation ¶
Index ¶
- func GetObjectIDFromString(s string) (bson.ObjectId, error)
- type DbEntryBase
- type EntryErrorPair
- type EntryErrorPairs
- type MongoCollection
- func (c *MongoCollection) Create(factoryFuncParams interface{}) (entry MongoEntry, err error)
- func (c *MongoCollection) CreateBulk(factoryFuncParamSet []interface{}) (entries []MongoEntry, err error)
- func (c *MongoCollection) Delete(entryID string) (status error)
- func (c *MongoCollection) DeleteAll() (status error)
- func (c *MongoCollection) Insert(entry MongoEntry) (err error)
- func (c *MongoCollection) InsertBulk(entries []MongoEntry) (err error)
- func (c *MongoCollection) MutexExec(cb func())
- func (c *MongoCollection) Read(entryID string, result MongoEntry) bool
- func (c *MongoCollection) ReadAll(result interface{}) (err error)
- func (c *MongoCollection) SetFactoryFunc(factoryFunc func(*MongoCollection, interface{}) MongoEntry)
- func (c *MongoCollection) Update(entryID string, factoryFuncParam interface{}) (entry MongoEntry, status error)
- type MongoDb
- func (db *MongoDb) Connect(dsn string) error
- func (db *MongoDb) Disconnect()
- func (db *MongoDb) Find(coll string, query map[string]interface{}, v interface{}) error
- func (db *MongoDb) FindAll(coll string, v interface{}) error
- func (db *MongoDb) FindById(coll string, id string, v interface{}) bool
- func (db *MongoDb) Insert(coll string, v ...interface{}) error
- func (db *MongoDb) Remove(coll string, id interface{}) error
- func (db *MongoDb) RemoveAll(coll string) error
- func (db *MongoDb) SessExec(cb func(*mgo.Session))
- func (db *MongoDb) Update(coll string, id interface{}, v interface{}) error
- type MongoEntry
- type MongoStorageInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DbEntryBase ¶
func (*DbEntryBase) BsonID ¶
func (e *DbEntryBase) BsonID() bson.ObjectId
func (*DbEntryBase) SetBsonID ¶
func (e *DbEntryBase) SetBsonID(id bson.ObjectId)
type EntryErrorPair ¶
type EntryErrorPair struct { Entry MongoEntry Error error }
type EntryErrorPairs ¶
type EntryErrorPairs []EntryErrorPair
func (*EntryErrorPairs) CheckPartFail ¶
func (p *EntryErrorPairs) CheckPartFail() bool
func (*EntryErrorPairs) MakeEntrySlice ¶
func (p *EntryErrorPairs) MakeEntrySlice() []MongoEntry
type MongoCollection ¶
type MongoCollection struct { sync.Mutex MongoStorageInfo // contains filtered or unexported fields }
MongoCollection represents abstact collection in MongoDB. It supports CRUD but should not be used directly. Instead you have to write a wrapper for your own data type.
func NewMongoCollection ¶
func NewMongoCollection(dbInstance *MongoDb, collName string) *MongoCollection
NewMongoCollection creates a new instance of the MongoDB collection.
func (*MongoCollection) Create ¶
func (c *MongoCollection) Create(factoryFuncParams interface{}) (entry MongoEntry, err error)
Create creates a new entry from specified param and factory function and inserts it into database. Please note that unless your factory depends on items in the collection you should run Insert instead.
func (*MongoCollection) CreateBulk ¶
func (c *MongoCollection) CreateBulk(factoryFuncParamSet []interface{}) (entries []MongoEntry, err error)
func (*MongoCollection) Delete ¶
func (c *MongoCollection) Delete(entryID string) (status error)
Delete removes entry from the database.
func (*MongoCollection) DeleteAll ¶
func (c *MongoCollection) DeleteAll() (status error)
DeleteAll removes all entries from the collection.
func (*MongoCollection) Insert ¶
func (c *MongoCollection) Insert(entry MongoEntry) (err error)
Insert adds a ready-made entry into the database.
func (*MongoCollection) InsertBulk ¶
func (c *MongoCollection) InsertBulk(entries []MongoEntry) (err error)
func (*MongoCollection) MutexExec ¶
func (c *MongoCollection) MutexExec(cb func())
func (*MongoCollection) Read ¶
func (c *MongoCollection) Read(entryID string, result MongoEntry) bool
Read returns the entry that matches specified entry ID.
func (*MongoCollection) ReadAll ¶
func (c *MongoCollection) ReadAll(result interface{}) (err error)
ReadAll returns all entries in the database. The first argument *must* be a pointer to a slice.
func (*MongoCollection) SetFactoryFunc ¶
func (c *MongoCollection) SetFactoryFunc(factoryFunc func(*MongoCollection, interface{}) MongoEntry)
SetFactoryFunc sets the object factory function used by Create for creation of new objects.
func (*MongoCollection) Update ¶
func (c *MongoCollection) Update(entryID string, factoryFuncParam interface{}) (entry MongoEntry, status error)
Update modifies entry based on input parameters.
type MongoDb ¶
type MongoDb struct {
// contains filtered or unexported fields
}
func (*MongoDb) Disconnect ¶
func (db *MongoDb) Disconnect()