func (c *Collection) Upsert(selector interface{}, update interface{}) (info *ChangeInfo, err error) {
	lerr, err := c.writeQuery(&updateOp{c.FullName, selector, update, 1})
	if err == nil && lerr != nil {
		info = &ChangeInfo{}
		if lerr.UpdatedExisting {
			info.Updated = lerr.N
		} else {
			info.UpsertedId = lerr.UpsertedId
		}
	}
	return info, err
}
func (c *Collection) Upsert(selector interface{}, update interface{}) (info *ChangeInfo, err error) {
	lerr, err := c.writeQuery(&updateOp{c.FullName, selector, update, 1})
	if err == nil && lerr != nil {
		info = &ChangeInfo{}
		if lerr.UpdatedExisting {
			info.Updated = lerr.N
		} else {
			info.UpsertedId = lerr.UpsertedId
		}
	}
	return info, err
}
func ( c * Collection ) Upsert ( selector interface { } , update interface { } ) ( info * ChangeInfo , err error ) { lerr , err := c . writeQuery ( & updateOp { c . FullName , selector , update , 1 } ) if err == nil && lerr != nil { info = & ChangeInfo { } if lerr . UpdatedExisting { info . Updated = lerr . N } else { info . UpsertedId = lerr . UpsertedId } } return info , err }
// Upsert finds a single document matching the provided selector document
// and modifies it according to the update document.  If no document matching
// the selector is found, the update document is applied to the selector
// document and the result is inserted in the collection.
// If the session is in safe mode (see SetSafe) details of the executed
// operation are returned in info, or an error of type *LastError when
// some problem is detected.
//
// Relevant documentation:
//
//     http://www.mongodb.org/display/DOCS/Updating
//     http://www.mongodb.org/display/DOCS/Atomic+Operations
//
Upsert finds a single document matching the provided selector document and modifies it according to the update document . If no document matching the selector is found the update document is applied to the selector document and the result is inserted in the collection . If the session is in safe mode ( see SetSafe ) details of the executed operation are returned in info or an error of type * LastError when some problem is detected . Relevant documentation : http : // www . mongodb . org / display / DOCS / Updating http : // www . mongodb . org / display / DOCS / Atomic + Operations