diff --git a/util/adapter/nonexistent.go b/util/adapter/nonexistent.go index 37587b511c2edd6f2b57427f877f0a555a487af6..2139ca755a66d22fdc34747693a821bf8775606f 100644 --- a/util/adapter/nonexistent.go +++ b/util/adapter/nonexistent.go @@ -39,22 +39,28 @@ func err(e error) error { return e } +// NonExistentCollection represents a collection that does not exist. type NonExistentCollection struct { Err error } +// NonExistentResult represents a result set that was based on a non existent +// collection and therefore does not exist. type NonExistentResult struct { Err error } +// Append returns error. func (c *NonExistentCollection) Append(interface{}) (interface{}, error) { return nil, err(c.Err) } +// Exists returns false. func (c *NonExistentCollection) Exists() bool { return false } +// Find returns a NonExistentResult. func (c *NonExistentCollection) Find(...interface{}) db.Result { if c.Err != nil { return &NonExistentResult{Err: c.Err} @@ -62,62 +68,77 @@ func (c *NonExistentCollection) Find(...interface{}) db.Result { return &NonExistentResult{Err: fmt.Errorf("Collection reported an error: %q", err(c.Err))} } +// Truncate returns error. func (c *NonExistentCollection) Truncate() error { return err(c.Err) } +// Name returns an empty string. func (c *NonExistentCollection) Name() string { return "" } +// Limit returns a NonExistentResult. func (r *NonExistentResult) Limit(uint) db.Result { return r } +// Skip returns a NonExistentResult. func (r *NonExistentResult) Skip(uint) db.Result { return r } +// Sort returns a NonExistentResult. func (r *NonExistentResult) Sort(...interface{}) db.Result { return r } +// Select returns a NonExistentResult. func (r *NonExistentResult) Select(...interface{}) db.Result { return r } +// Where returns a NonExistentResult. func (r *NonExistentResult) Where(...interface{}) db.Result { return r } +// Group returns a NonExistentResult. func (r *NonExistentResult) Group(...interface{}) db.Result { return r } +// Remove returns error. func (r *NonExistentResult) Remove() error { return err(r.Err) } +// Update returns error. func (r *NonExistentResult) Update(interface{}) error { return err(r.Err) } +// Count returns 0 and error. func (r *NonExistentResult) Count() (uint64, error) { return 0, err(r.Err) } +// Next returns error. func (r *NonExistentResult) Next(interface{}) error { return err(r.Err) } +// One returns error. func (r *NonExistentResult) One(interface{}) error { return err(r.Err) } +// All returns error. func (r *NonExistentResult) All(interface{}) error { return err(r.Err) } +// Close returns error. func (r *NonExistentResult) Close() error { return err(r.Err) }