Documentation
¶
Overview ¶
Package mock contains mocked implementations of the interfaces defined in the anser package.
These implementations expose all internals and do not have external dependencies. Indeed they should have interface-definition-only dependencies on other anser packages.
Index ¶
- type Client
- type Collection
- func (c *Collection) Aggregate(ctx context.Context, pipe interface{}, opts ...*options.AggregateOptions) (client.Cursor, error)
- func (c *Collection) Find(ctx context.Context, query interface{}, opts ...*options.FindOptions) (client.Cursor, error)
- func (c *Collection) FindOne(ctx context.Context, query interface{}, opts ...*options.FindOneOptions) client.SingleResult
- func (c *Collection) InsertMany(ctx context.Context, docs []interface{}) (*client.InsertManyResult, error)
- func (c *Collection) InsertOne(ctx context.Context, doc interface{}) (*client.InsertOneResult, error)
- func (c *Collection) Name() string
- func (c *Collection) ReplaceOne(ctx context.Context, query, update interface{}, ...) (*client.UpdateResult, error)
- func (c *Collection) UpdateMany(ctx context.Context, query, update interface{}, opts ...*options.UpdateOptions) (*client.UpdateResult, error)
- func (c *Collection) UpdateOne(ctx context.Context, query, update interface{}, opts ...*options.UpdateOptions) (*client.UpdateResult, error)
- type Cursor
- type Database
- func (d *Database) Client() client.Client
- func (d *Database) Collection(name string) client.Collection
- func (d *Database) Name() string
- func (d *Database) RunCommand(ctx context.Context, cmd interface{}) client.SingleResult
- func (d *Database) RunCommandCursor(ctx context.Context, cmd interface{}) (client.Cursor, error)
- type Iterator
- type LegacyCollection
- func (c *LegacyCollection) Bulk() db.Bulk
- func (c *LegacyCollection) Count() (int, error)
- func (c *LegacyCollection) DropCollection() error
- func (c *LegacyCollection) Find(q interface{}) db.Query
- func (c *LegacyCollection) FindId(q interface{}) db.Query
- func (c *LegacyCollection) Insert(docs ...interface{}) error
- func (c *LegacyCollection) Pipe(p interface{}) db.Aggregation
- func (c *LegacyCollection) Remove(q interface{}) error
- func (c *LegacyCollection) RemoveAll(q interface{}) (*db.ChangeInfo, error)
- func (c *LegacyCollection) RemoveId(id interface{}) error
- func (c *LegacyCollection) Update(q, u interface{}) error
- func (c *LegacyCollection) UpdateAll(q, u interface{}) (*db.ChangeInfo, error)
- func (c *LegacyCollection) UpdateId(id, u interface{}) error
- func (c *LegacyCollection) Upsert(q, u interface{}) (*db.ChangeInfo, error)
- func (c *LegacyCollection) UpsertId(id, u interface{}) (*db.ChangeInfo, error)
- type LegacyDatabase
- type Pipeline
- type Query
- func (q *Query) All(r interface{}) error
- func (q *Query) Apply(ch db.Change, r interface{}) (*db.ChangeInfo, error)
- func (q *Query) Count() (int, error)
- func (q *Query) Hint(h interface{}) db.Query
- func (q *Query) Iter() db.Iterator
- func (q *Query) Limit(n int) db.Query
- func (q *Query) MaxTime(d time.Duration) db.Query
- func (q *Query) One(r interface{}) error
- func (q *Query) Select(p interface{}) db.Query
- func (q *Query) Skip(n int) db.Query
- func (q *Query) Sort(keys ...string) db.Query
- type Session
- type SingleResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
CollName string
UpdateResult client.UpdateResult
SingleResult *SingleResult
InsertManyResult client.InsertManyResult
InsertOneResult client.InsertOneResult
FindError error
}
func (*Collection) Aggregate ¶
func (c *Collection) Aggregate(ctx context.Context, pipe interface{}, opts ...*options.AggregateOptions) (client.Cursor, error)
func (*Collection) Find ¶
func (c *Collection) Find(ctx context.Context, query interface{}, opts ...*options.FindOptions) (client.Cursor, error)
func (*Collection) FindOne ¶
func (c *Collection) FindOne(ctx context.Context, query interface{}, opts ...*options.FindOneOptions) client.SingleResult
func (*Collection) InsertMany ¶
func (c *Collection) InsertMany(ctx context.Context, docs []interface{}) (*client.InsertManyResult, error)
func (*Collection) InsertOne ¶
func (c *Collection) InsertOne(ctx context.Context, doc interface{}) (*client.InsertOneResult, error)
func (*Collection) Name ¶
func (c *Collection) Name() string
func (*Collection) ReplaceOne ¶
func (c *Collection) ReplaceOne(ctx context.Context, query, update interface{}, opts ...*options.ReplaceOptions) (*client.UpdateResult, error)
func (*Collection) UpdateMany ¶
func (c *Collection) UpdateMany(ctx context.Context, query, update interface{}, opts ...*options.UpdateOptions) (*client.UpdateResult, error)
func (*Collection) UpdateOne ¶
func (c *Collection) UpdateOne(ctx context.Context, query, update interface{}, opts ...*options.UpdateOptions) (*client.UpdateResult, error)
type Cursor ¶
type Database ¶
type Database struct {
DBName string
Collections map[string]*Collection
}
func (*Database) Collection ¶
func (d *Database) Collection(name string) client.Collection
func (*Database) RunCommand ¶
func (d *Database) RunCommand(ctx context.Context, cmd interface{}) client.SingleResult
type Iterator ¶
type LegacyCollection ¶
type LegacyCollection struct {
Name string
InsertedDocs []interface{}
UpdatedIds []interface{}
FailWrites bool
Queries []*Query
Pipelines []*Pipeline
NumDocs int
QueryError error
Mutex sync.Mutex
}
func (*LegacyCollection) Bulk ¶
func (c *LegacyCollection) Bulk() db.Bulk
func (*LegacyCollection) Count ¶
func (c *LegacyCollection) Count() (int, error)
func (*LegacyCollection) DropCollection ¶
func (c *LegacyCollection) DropCollection() error
func (*LegacyCollection) Find ¶
func (c *LegacyCollection) Find(q interface{}) db.Query
func (*LegacyCollection) FindId ¶
func (c *LegacyCollection) FindId(q interface{}) db.Query
func (*LegacyCollection) Insert ¶
func (c *LegacyCollection) Insert(docs ...interface{}) error
func (*LegacyCollection) Pipe ¶
func (c *LegacyCollection) Pipe(p interface{}) db.Aggregation
func (*LegacyCollection) Remove ¶
func (c *LegacyCollection) Remove(q interface{}) error
func (*LegacyCollection) RemoveAll ¶
func (c *LegacyCollection) RemoveAll(q interface{}) (*db.ChangeInfo, error)
func (*LegacyCollection) RemoveId ¶
func (c *LegacyCollection) RemoveId(id interface{}) error
func (*LegacyCollection) Update ¶
func (c *LegacyCollection) Update(q, u interface{}) error
func (*LegacyCollection) UpdateAll ¶
func (c *LegacyCollection) UpdateAll(q, u interface{}) (*db.ChangeInfo, error)
func (*LegacyCollection) UpdateId ¶
func (c *LegacyCollection) UpdateId(id, u interface{}) error
func (*LegacyCollection) Upsert ¶
func (c *LegacyCollection) Upsert(q, u interface{}) (*db.ChangeInfo, error)
func (*LegacyCollection) UpsertId ¶
func (c *LegacyCollection) UpsertId(id, u interface{}) (*db.ChangeInfo, error)
type LegacyDatabase ¶
type LegacyDatabase struct {
Collections map[string]*LegacyCollection
DBName string
Mutex sync.Mutex
}
func (*LegacyDatabase) C ¶
func (d *LegacyDatabase) C(n string) db.Collection
func (*LegacyDatabase) CreateCollection ¶
func (d *LegacyDatabase) CreateCollection(coll string) (db.Collection, error)
func (*LegacyDatabase) DropDatabase ¶
func (d *LegacyDatabase) DropDatabase() error
func (*LegacyDatabase) Name ¶
func (d *LegacyDatabase) Name() string
type Pipeline ¶
type Pipeline struct {
Pipe interface{}
Error error
}
func (*Pipeline) Hint ¶
func (p *Pipeline) Hint(hint interface{}) db.Aggregation
type Query ¶
type Session ¶
type Session struct {
DBs map[string]*LegacyDatabase
URI string
Closed bool
SocketTimeout time.Duration
Mutex sync.Mutex
}
func NewSession ¶
func NewSession() *Session
func (*Session) SetSocketTimeout ¶
type SingleResult ¶
type SingleResult struct {
DecodeError error
DecodeBytesError error
DecodeBytesValue []byte
ErrorValue error
}
func NewSingleResult ¶
func NewSingleResult() *SingleResult
func (*SingleResult) Decode ¶
func (sr *SingleResult) Decode(in interface{}) error
func (*SingleResult) Err ¶
func (sr *SingleResult) Err() error
func (*SingleResult) Raw ¶
func (sr *SingleResult) Raw() ([]byte, error)
Click to show internal directories.
Click to hide internal directories.