Convert this update description to an update document.

@return an update document with the appropriate $set and $unset documents.
336451
public BsonDocument toUpdateDocument() {
    final List<BsonElement> unsets = new ArrayList<>();
    for (final String removedField : this.removedFields) {
      unsets.add(new BsonElement(removedField, new BsonBoolean(true)));
    }
    final BsonDocument updateDocument = new BsonDocument();

    if (this.updatedFields.size() > 0) {
      updateDocument.append("$set", this.updatedFields);
    }

    if (unsets.size() > 0) {
      updateDocument.append("$unset", new BsonDocument(unsets));
    }

    return updateDocument;
  }
797860
public static UpdateDescription fromBsonDocument(final BsonDocument document) {
    keyPresent(Fields.UPDATED_FIELDS_FIELD, document);
    keyPresent(Fields.REMOVED_FIELDS_FIELD, document);

    final BsonArray removedFieldsArr =
        document.getArray(Fields.REMOVED_FIELDS_FIELD);
    final Set<String> removedFields = new HashSet<>(removedFieldsArr.size());
    for (final BsonValue field : removedFieldsArr) {
      removedFields.add(field.asString().getValue());
    }

    return new UpdateDescription(document.getDocument(Fields.UPDATED_FIELDS_FIELD), removedFields);
  }
980753
def apply_update(self, doc, update_spec):
        """"""
        # Replace a whole document
        if not '$set' in update_spec and not '$unset' in update_spec:
            # update_spec contains the new document.
            # Update the key in Solr based on the unique_key mentioned as
            # parameter.
            update_spec['_id'] = doc[self.unique_key]
            return update_spec
        for to_set in update_spec.get("$set", []):
            value = update_spec['$set'][to_set]
            # Find dotted-path to the value, remove that key from doc, then
            # put value at key:
            keys_to_pop = []
            for key in doc:
                if key.startswith(to_set):
                    if key == to_set or key[len(to_set)] == '.':
                        keys_to_pop.append(key)
            for key in keys_to_pop:
                doc.pop(key)
            doc[to_set] = value
        for to_unset in update_spec.get("$unset", []):
            # MongoDB < 2.5.2 reports $unset for fields that don't exist within
            # the document being updated.
            keys_to_pop = []
            for key in doc:
                if key.startswith(to_unset):
                    if key == to_unset or key[len(to_unset)] == '.':
                        keys_to_pop.append(key)
            for key in keys_to_pop:
                doc.pop(key)
        return doc
1023469
private function update() {
        // pre-processing hook
        if ($this->beforeUpdate() !== true)
            return $this;

        $mapping = $this->dao()->getMapping();
        $changes = [];

        // collect modified properties and their values
        foreach ($mapping['properties'] as $property) {                 // TODO: Until the dirty check is implemented all
            $propertyName = $property['name'];                          //       properties are assumed dirty.
            $changes[$propertyName] = $this->$propertyName;
        }

        // perform update
        if ($this->doUpdate($changes)) {
            $this->_modified = false;

            // post-processing hook
            $this->afterUpdate();
        }
        return $this;
    }
1193508
public static Update update(Update... update) {
        if (update.length == 1) {
            return update[0];
        } else {
            Update x = new Update(true);
            for (Update u : update) {
                ((ArrayNode) x.node).add(u.toJson());
            }
            return x;
        }
    }
26603
def update(collection_name, upsert, multi,
           spec, doc, safe, last_error_args, check_keys, opts):
    
    options = 0
    if upsert:
        options += 1
    if multi:
        options += 2

    data = _ZERO_32
    data += bson._make_c_string(collection_name)
    data += struct.pack("<i", options)
    data += bson.BSON.encode(spec, False, opts)
    encoded = bson.BSON.encode(doc, check_keys, opts)
    data += encoded
    if safe:
        (_, update_message) = __pack_message(2001, data)
        (request_id, error_message, _) = __last_error(collection_name,
                                                      last_error_args)
        return (request_id, update_message + error_message, len(encoded))
    else:
        (request_id, update_message) = __pack_message(2001, data)
        return (request_id, update_message, len(encoded))
1300841
final public function updateNotNull() {
	
		$class		= get_called_class();
		$binds		= $class::getBinds();
		$properties	= array();
		
		foreach ($binds as $objProp => $dbField) {
				
			if (!is_null($this->$objProp))  {
				$properties[] = $objProp;
			}
				
		}
		
		$ret = $this->update($properties);
		
		return $ret;

	}
1259587
private function internalUpdate()
    {
        if ($this->triggerEvent(self::EVENT_NAME_BEFORE_UPDATE)->isCancelled()) {
            return;
        }

        // locking
        $query = array('_id' => $this->getId());
        if ($this->getOption('lock') === Definition::LOCK_OPTIMISTIC) {
            $query['__version__'] = $this->get('__version__');
            $this->getOperator()->increment('__version__');
        }

        // update
        try {
            $status = $this
                ->collection
                ->getMongoCollection()
                ->update(
                    $query,
                    $this->getOperator()->toArray()
                );
        } catch (\Exception $e) {
            throw new WriteException(
                $e->getMessage(),
                $e->getCode(),
                $e
            );
        }

        // check update status
        if ($status['ok'] != 1) {
            throw new WriteException(
                sprintf(
                    'Update error: %s: %s',
                    $status['err'],
                    $status['errmsg']
                )
            );
        }

        // check if document modified due to specified lock
        if ($this->getOption('lock') === Definition::LOCK_OPTIMISTIC) {
            if ($status['n'] === 0) {
                throw new OptimisticLockFailureException;
            }
        }

        if ($this->getOperator()->isReloadRequired()) {
            $this->refresh();
        } else {
            $this->getOperator()->reset();
        }

        $this->triggerEvent(self::EVENT_NAME_AFTER_UPDATE);
    }
550897
public function update($set = array())
    {
        if (is_array($set)) {
            $params = array();
            foreach ($set as $field => $param) {
                $this->add('set', $field . ' = ?', true);
                $params[] = $param;
            }
            $this->params = array_merge($params, $this->params);
        } else {
            $this->add('set', $set, true);
        }
        $this->type = self::UPDATE;
        return $this->execute();
    }
283058
protected function getFieldsToUpdate()
    {
        $toUpdate = array();

        $fields     = $this->_item->getFields();
        $origFields = $this->_item->getOrigFields();
        foreach ($fields as $field => $value) {
            if (! array_key_exists($field, $origFields) or $value != $origFields[$field]) {
                $toUpdate[$field] = $value;
            }
        }

        return $toUpdate;
    }
998849
public function getUpdated()
    {
        $set = new ArrayList();
        foreach ($this->updated as $arrItem) {
            $set->push(ArrayData::create($arrItem));
        }
        return $set;
    }
176214
@Override
  public BsonDocument toBsonDocument() {
    final BsonDocument asDoc = new BsonDocument();
    asDoc.put(Fields.ID_FIELD, id);

    asDoc.put(Fields.OPERATION_TYPE_FIELD, new BsonString(getOperationType().toRemote()));

    final BsonDocument nsDoc = new BsonDocument();
    nsDoc.put(Fields.NS_DB_FIELD, new BsonString(ns.getDatabaseName()));
    nsDoc.put(Fields.NS_COLL_FIELD, new BsonString(getNamespace().getCollectionName()));
    asDoc.put(Fields.NS_FIELD, nsDoc);

    asDoc.put(Fields.DOCUMENT_KEY_FIELD, getDocumentKey());

    if (getFullDocument() != null && (getFullDocument() instanceof BsonValue)
        && ((BsonValue) getFullDocument()).isDocument()) {
      asDoc.put(Fields.FULL_DOCUMENT_FIELD, (BsonValue) getFullDocument());
    }

    if (getUpdateDescription() != null) {
      asDoc.put(Fields.UPDATE_DESCRIPTION_FIELD, getUpdateDescription().toBsonDocument());
    }

    asDoc.put(Fields.WRITE_PENDING_FIELD, new BsonBoolean(hasUncommittedWrites()));
    return asDoc;
  }
684870
function update() {
		$where = $this->criteria();
		$this->table->notify($this, "update", $where);
		$rowset = $this->table->update($where, $this->changes());
		if (!count($rowset)) {
			throw new \UnexpectedValueException("No row updated");
		}
		$this->data = $rowset->current()->data;
		$this->cell = array();
		return $this;
	}
786936
public BsonDocument toBsonDocument() {
    final BsonDocument updateDescDoc = new BsonDocument();
    updateDescDoc.put(
        Fields.UPDATED_FIELDS_FIELD,
        this.getUpdatedFields());

    final BsonArray removedFields = new BsonArray();
    for (final String field : this.getRemovedFields()) {
      removedFields.add(new BsonString(field));
    }
    updateDescDoc.put(
        Fields.REMOVED_FIELDS_FIELD,
        removedFields);

    return updateDescDoc;
  }
1197567
public function update()
    {
        self::$instance->reset();
        $this->sql('UPDATE');

        $numargs = func_num_args();

        if ($numargs > 0) {
            $arg_list = func_get_args();

            $this->oosql_multiFlag = true;

            $this->oosql_multi = $arg_list;

            for ($i = 0; $i < $numargs; $i++) {
                if ($i != 0 && $numargs > $i) {
                    $this->sql(',');
                }
                $this->sql(' ' . $arg_list[$i]);
            }
        } else {
            $this->sql(" $this->oosql_table");
        }

        $this->sql(' SET ');
        $this->oosql_where = null;
        return $this;
    }
318198
protected function _update()
    {
        if (($this->_blWasSubscribed || $this->_blWasPreSubscribed) && !$this->oxnewssubscribed__oxdboptin->value) {
            // set unsubscription date
            $this->oxnewssubscribed__oxunsubscribed->setValue(date('Y-m-d H:i:s'));
            // 0001974 Same object can be called many times without requiring to renew date.
            // If so happens, it would have _aSkipSaveFields set to skip date field. So need to check and
            // release if _aSkipSaveFields are set for field oxunsubscribed.
            $aSkipSaveFieldsKeys = array_keys($this->_aSkipSaveFields, 'oxunsubscribed');
            foreach ($aSkipSaveFieldsKeys as $iSkipSaveFieldKey) {
                unset($this->_aSkipSaveFields[$iSkipSaveFieldKey]);
            }
        } else {
            // don't update date
            $this->_aSkipSaveFields[] = 'oxunsubscribed';
        }

        return parent::_update();
    }
771030
public Response update(String id, Object document) {
        Misc.checkNotNullOrEmpty(id, "id");
        Misc.checkNotNull(document, "Document");

        // Get the latest rev, will throw if doc doesn't exist
        getDocumentRev(id);

        return putUpdate(id, document);
    }