~ubuntu-branches/ubuntu/trusty/juju-core/trusty-proposed

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/state/collections.go

  • Committer: Package Import Robot
  • Author(s): Robie Basak
  • Date: 2015-07-15 13:09:07 UTC
  • mfrom: (35.1.15 wily-proposed)
  • Revision ID: package-import@ubuntu.com-20150715130907-wqak1zpebzzdvy3q
Tags: 1.22.6-0ubuntu1~14.04.1
* No change backport to 14.04 (LP: #1469744). This results in the
  following packaging delta from the previous 1.20.11-0ubuntu0.14.04.1
  in trusty-updates:
  - distro-info added and libgo5 removed from Build-Depends.
  - Standards-Version bumped.
  - cloud-image-utils | cloud-utils added to juju-local Depends.
  - d/copyright updated.
  - dep8 tests updated.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
        Find(query interface{}) *mgo.Query
52
52
        FindId(id interface{}) *mgo.Query
53
53
        Insert(docs ...interface{}) error
 
54
        Update(selector interface{}, update interface{}) error
 
55
        UpdateId(id interface{}, update interface{}) error
54
56
        Remove(sel interface{}) error
55
57
        RemoveId(id interface{}) error
56
58
        RemoveAll(sel interface{}) (*mgo.ChangeInfo, error)
165
167
        return c.Collection.FindId(c.mungeId(id))
166
168
}
167
169
 
 
170
// Update finds a single document matching the provided query document and
 
171
// modifies it according to the update document.
 
172
//
 
173
// An "env-uuid" condition will always be added to the query to ensure
 
174
// that only data for the environment being filtered on is returned.
 
175
//
 
176
// If a simple "_id" field selector is included in the query
 
177
// (e.g. "{{"_id", "foo"}}" the relevant environment UUID prefix will
 
178
// be added on to the id. Note that more complex selectors using the
 
179
// "_id" field (e.g. using the $in operator) will not be modified. In
 
180
// these cases it is up to the caller to add environment UUID
 
181
// prefixes when necessary.
 
182
func (c *envStateCollection) Update(query interface{}, update interface{}) error {
 
183
        return c.Collection.Update(c.mungeQuery(query), update)
 
184
}
 
185
 
 
186
// UpdateId finds a single document by _id and modifies it according to the
 
187
// update document. The id must be a string or bson.ObjectId. The environment
 
188
// UUID will be automatically prefixed on to the id if it's a string and the
 
189
// prefix isn't there already.
 
190
func (c *envStateCollection) UpdateId(id interface{}, update interface{}) error {
 
191
        return c.Collection.UpdateId(c.mungeId(id), update)
 
192
}
 
193
 
168
194
// Remove deletes a single document using the query provided. The
169
195
// query will be handled as per Find().
170
196
func (c *envStateCollection) Remove(query interface{}) error {