Documentation ¶
Overview ¶
The MIT License (MIT)
Copyright (c) 2014 Greivin López ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Variables
- type MongoDBPersistor
- func (mongo *MongoDBPersistor) Count(collectionName string) (n int, err error)
- func (mongo *MongoDBPersistor) Create(document interface{}, collection string) (err error)
- func (mongo *MongoDBPersistor) Delete(cache skue.MemoryCacher, collection string, idfield string, id interface{}) (err error)
- func (mongo *MongoDBPersistor) Drop(collectionName string) (err error)
- func (mongo *MongoDBPersistor) DropIndexes(collection *mgo.Collection) (err error)
- func (mongo *MongoDBPersistor) List(documents interface{}, collection string, query interface{}, limit int) (err error)
- func (mongo *MongoDBPersistor) Read(cache skue.MemoryCacher, document interface{}, collection string, ...) (err error)
- func (mongo *MongoDBPersistor) Update(cache skue.MemoryCacher, document interface{}, collection string, ...) (err error)
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = mgo.ErrNotFound
Functions ¶
This section is empty.
Types ¶
type MongoDBPersistor ¶
type MongoDBPersistor struct {
// contains filtered or unexported fields
}
func New ¶
func New(address, username, password, database string) *MongoDBPersistor
New creates a new MongoDBPersistor. This persistor will interact with a MongoDB server. The parameters represents the values to dial the server. Dial information to connect with your MongoDB server: - address= The address where your MongoDB server is running - username= The username for your connection user - password= The password for your connection user - database= The name of the database to work with
func (*MongoDBPersistor) Count ¶
func (mongo *MongoDBPersistor) Count(collectionName string) (n int, err error)
Count returns the number of elements of the given collection
func (*MongoDBPersistor) Create ¶
func (mongo *MongoDBPersistor) Create(document interface{}, collection string) (err error)
Create saves the given document into the provided collection
func (*MongoDBPersistor) Delete ¶
func (mongo *MongoDBPersistor) Delete(cache skue.MemoryCacher, collection string, idfield string, id interface{}) (err error)
Delete removes the document associated with the given collection+id from the database and from the cache system given if any.
func (*MongoDBPersistor) Drop ¶
func (mongo *MongoDBPersistor) Drop(collectionName string) (err error)
Drop removes all the elements from the given collection
func (*MongoDBPersistor) DropIndexes ¶
func (mongo *MongoDBPersistor) DropIndexes(collection *mgo.Collection) (err error)
DropIndexes removes the indexes from the given collection
func (*MongoDBPersistor) List ¶
func (mongo *MongoDBPersistor) List(documents interface{}, collection string, query interface{}, limit int) (err error)
Gets a list of documents from the given collection
func (*MongoDBPersistor) Read ¶
func (mongo *MongoDBPersistor) Read(cache skue.MemoryCacher, document interface{}, collection string, idfield string, id interface{}) (err error)
Read retrieves the document associated with the given collection+id trying the given memory cache first.
func (*MongoDBPersistor) Update ¶
func (mongo *MongoDBPersistor) Update(cache skue.MemoryCacher, document interface{}, collection string, idfield string, id interface{}) (err error)
Update changes the given document on the database (and the given cache if not nil)