Updates a collection
@param string $collection_id
180472
protected function updateCollection($collection_id)
    {
        if (!$this->isError() && !$this->collection->update($collection_id, $this->getSubmitted())) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
455977
public function add($collectionName, array $data, $id=null, $user_id=null)
    {
        $payload = ["id" => $id, "data" => $data, "user_id" => $user_id];
        $response = $this->doRequest('POST', 'collections/' . $collectionName . '/', $payload);
        $body = $response->getBody()->getContents();
        return json_decode($body, true);
    }
224449
protected function postCollectionModifiers(Collection $collection)
    {
        if ($this->getOrderByField() && $this->getOrderByDirection()) {
            $field = $this->getOrderByField();
            $desc  = false;

            if ($this->getOrderByDirection() === 'desc') {
                $desc = true;
            }

            $sorted = $collection->sortBy(function ($entry) use ($field) {
                if (property_exists($entry, $field)) {
                    return $entry->{$field};
                }
            }, SORT_NATURAL, $desc);

            return $sorted;
        }

        return $collection;
    }
539010
public function update(object $parent, array $collections, array $options) : void
    {
        $setStrategyColls     = [];
        $addPushStrategyColls = [];

        foreach ($collections as $coll) {
            $mapping = $coll->getMapping();

            if ($mapping['isInverseSide']) {
                continue; // ignore inverse side
            }
            switch ($mapping['strategy']) {
                case ClassMetadata::STORAGE_STRATEGY_ATOMIC_SET:
                case ClassMetadata::STORAGE_STRATEGY_ATOMIC_SET_ARRAY:
                    throw new UnexpectedValueException($mapping['strategy'] . ' update collection strategy should have been handled by DocumentPersister. Please report a bug in issue tracker');

                case ClassMetadata::STORAGE_STRATEGY_SET:
                case ClassMetadata::STORAGE_STRATEGY_SET_ARRAY:
                    $setStrategyColls[] = $coll;
                    break;

                case ClassMetadata::STORAGE_STRATEGY_ADD_TO_SET:
                case ClassMetadata::STORAGE_STRATEGY_PUSH_ALL:
                    $addPushStrategyColls[] = $coll;
                    break;

                default:
                    throw new UnexpectedValueException('Unsupported collection strategy: ' . $mapping['strategy']);
            }
        }

        if (! empty($setStrategyColls)) {
            $this->setCollections($parent, $setStrategyColls, $options);
        }
        if (empty($addPushStrategyColls)) {
            return;
        }

        $this->deleteElements($parent, $addPushStrategyColls, $options);
        $this->insertElements($parent, $addPushStrategyColls, $options);
    }
499915
protected function updateCollection()
    {
        $this->controlAccess('collection_edit');

        if ($this->collection->update($this->data_collection['collection_id'], $this->getSubmitted())) {
            $this->redirect('admin/content/collection', $this->text('Collection has been updated'), 'success');
        }

        $this->redirect('', $this->text('Collection has not been updated'), 'danger');
    }
353890
public function deleteCollection($collectionId, ?int $status = null): void
    {
        // Delete all connections between blocks and collections

        $query = $this->connection->createQueryBuilder();
        $query
            ->delete('ngbm_block_collection')
            ->where(
                $query->expr()->eq('collection_id', ':collection_id')
            )
            ->setParameter('collection_id', $collectionId, Type::INTEGER);

        if ($status !== null) {
            $this->applyStatusCondition($query, $status, 'collection_status');
        }

        $query->execute();

        // Then delete the collection itself

        $query = $this->connection->createQueryBuilder();
        $query->delete('ngbm_collection')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $collectionId, Type::INTEGER);

        if ($status !== null) {
            $this->applyStatusCondition($query, $status);
        }

        $query->execute();
    }
705267
public function cmdUpdateCollection()
    {
        $params = $this->getParam();

        if (empty($params[0]) || count($params) < 2) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        if (!is_numeric($params[0])) {
            $this->errorAndExit($this->text('Invalid argument'));
        }

        $this->setSubmitted(null, $params);
        $this->setSubmitted('update', $params[0]);
        $this->validateComponent('collection');

        $this->updateCollection($params[0]);
        $this->output();
    }
73054
private function trackCollection(Collection $collection)
    {
        $blocks = $collection->getBlocks();
        $this->trackBlocks($collection, $blocks);
    }
826898
private function processCollections(Block $block, array $collectionsData): void
    {
        foreach ($block->getCollections() as $identifier => $collection) {
            $collectionData = $collectionsData[$identifier];

            $collectionQuery = $collection->getQuery();

            if ($collectionQuery instanceof Query && is_array($collectionData['query'])) {
                $this->updateQueryTranslations(
                    $collectionQuery,
                    $collectionData['query']['parameters']
                );
            }

            $this->createItems($collection, $collectionData['items']);
        }
    }
729212
protected function saveCollection(Collection $collection) {
		if ($collection->count() === 1) {
			return $this->save($collection->getFirst());
		}

		$transaction = $this->getTransactionsManager()->get(true);

		foreach ($collection as $model) {
			if (! $this->saveThroughPhalconModel($model, $transaction)) {
				$transaction->rollback();
			}
		}

		$transaction->commit();
		return true;
	}
1304390
public function setData($collection, $resource_name = '')
    {
        $this->collection = collect();

        if (!$this->resource_name) {
            $this->resource_name = empty($resource_name) ? 'undefined' : $resource_name;
        }

        $this->data = [];
        
        foreach ($collection as $item) {
            $this->collection->push(clone $item);
            $i = new Item($item, $this->resource_name);
            array_push($this->data, $i->getData());
        }
        $this->response['data'] = $this->data;
    }
1060152
public function update($collectionName, array $data, array $where)
    {
        $collection = $this->db->selectCollection($this->dbName, $collectionName);
        return $collection->update($where, $data);
    }
103424
protected function setCollectionCollectionItem($collection_item_id)
    {
        $this->data_collection_item = array();

        if (is_numeric($collection_item_id)) {

            $this->data_collection_item = $this->collection_item->get($collection_item_id);

            if (empty($this->data_collection_item)) {
                $this->outputHttpStatus(404);
            }

            $this->prepareCollectionItem($this->data_collection_item);
        }
    }
1148672
public function update(array $collection)
    {
        $this->_auth = Yii::$app->authManager;
        $this->generateItems($collection);
        $this->manageItems();
        $this->manageRelations();
        if ($this->_auth instanceof \yii\rbac\DbManager) {
            $this->_auth->invalidateCache();
        }
    }
48668
public function getListEntities($collection_id, array $arguments)
    {
        try {
            $handlers = $this->collection->getHandlers();
            return Handler::call($handlers, $collection_id, 'list', array($arguments));
        } catch (Exception $ex) {
            trigger_error($ex->getMessage());
            return array();
        }
    }
729238
public function removeCollection($id)
    {
        unset($this->_collections[$id]);
        $this->clearSchema();

        $this->getLogger()->debug('Collection removed', array('collection' => $id));

        return $this;
    }
296702
function updateCollection(id, collID, collObj) {
  return updateItem(id, item => {
    const pos = item.dataset.findIndex(e => e.collectionID === collID);
    if (_.isFunction(collObj)) {
      collObj(item.dataset[pos]);
    } else {
      item.dataset[pos] = collObj;
    }
  });
}