Save items

@return \Purekid\Mongodm\Collection
177431
public function save(){

        foreach($this->_items as $item){
            if($item->exists()){
                $item->save();
            }
        }

        return $this;

    }
1086456
public function save()
    {
        $result = false;

        if (count($this))
        {
            $result = true;

            foreach ($this as $entity)
            {
                if (!$entity->save())
                {
                    // Set current entity status message as collection status message.
                    $this->setStatusMessage($entity->getStatusMessage());
                    $result = false;
                }
            }
        }

        return $result;
    }
1187690
public function toCollection() {
		$data  = iterator_to_array($this->_iterator);
		$model = $this->getModel();
		
		$collection = new Collection($data, $model);

		if ($this->hasDatagate()) {
			$collection->setDatagate($this->getDatagate());
		}
		
		if ($this->hasLocator()) {
			$collection->setLocator($this->getLocator());
		}
		
		return $collection;
	}
428698
public function save()
    {
        $id = $this->getQuery()->saveById($this->id, $this->toArray());
        if (is_null($this->id)) {
            $this->id = $id;
        }
        return $this;
    }
706307
public static function saveMany($datasets)
    {
        $models = [];

        if (! is_array($datasets)) {
            $datasets = [$datasets];
        }

        foreach ($datasets as $dataset) {
            $class = get_called_class();
            $model = new $class();

            // Assign attributes.
            foreach ($dataset as $attribute => $value) {
                $model->{$attribute} = $value;
            }

            $model->save();
            $models[] = $model;
        }

        return collect($models);
    }
1300031
public function save()
    {
        $rows   = $this->getMapper()
                       ->save( $this );
        $rootId = $this->getRootId();

        if ( ! $rootId )
        {
            $this->setRootId( $rootId = $this->getId() );
        }

        return $rows;
    }
1361547
public function bulkSave($collection = [])
    {
        $params = [];

        $defaultIndex = $this->connection->getDefaultIndex();

        foreach ($collection as $item) {
            $modelIndex = $item->getDocumentIndex();

            $params['body'][] = [
                'index' => [
                    '_id'    => $item->getKey(),
                    '_type'  => $item->getDocumentType(),
                    '_index' => $modelIndex ? $modelIndex : $defaultIndex,
                ],
            ];
            $params['body'][] = $item->getDocumentData();
        }

        return $this->connection->bulkStatement($params);
    }
1159590
protected function save()
    {
        $messages = [];
        foreach ([self::DURABLE, self::NEXT] as $when) {
            if (!empty($this->messages[$when])) {
                $messages[$when] = $this->messages[$when];
            }
        }

        if ($messages) {
            $messages = json_encode($messages);
            $this->cookie->set($this->cookieKey, $messages);
        } else {
            $this->cookie->remove($this->cookieKey);
        }

        return $this;
    }
162986
public function save()
    {
        if ($this->dirty)
        {
            $path = $this->manifestPath.'/collections.json';

            $this->dirty = false;

            return (bool) $this->files->put($path, $this->entries->toJson());
        }

        return false;
    }
1042233
public function save()
	{
		$result = $this->getClient()->save();
		$item = $this->getView()->item;

		if( $item->getId() !== null )
		{
			$idtag = 'product-' . $item->getId();
			$this->getContext()->getCache()->deleteByTags( array( 'product', $idtag ) );
		}

		return $result;
	}
28787
public function save()
    {
        $operations = [];

        $this->items->each(function ($item) use(&$operations) {
          $operation = $this->setOperator();
          $operation->setOperand($item);
          $operation->setOperator('SET');

          $operations[] = $operation;
        });

        if(empty($operations))
            return false;

        return $this->adWordsServices->mutate($operations)->getValue();
    }
58148
function copy( $collectionItemID )
    {
        $item = clone $this;
        $item->setAttribute( 'item_id', $collectionItemID );
        $item->store();
        return $item;
    }
1140871
protected function retrieveCollection()
    {
        $cache = new FilesystemAdapter($this->namespace);
        $item = $cache->getItem('collection');

        $collection = null;
        if ($item->isHit()) {
            $collection = $item->get('collection');
        }

        if (empty($collection) || !$collection instanceof ValuesCollection) {
            $collection = new ValuesCollection();
        }

        return $collection;
    }
932892
final public function saveValues() {
		// double check if we have collection object
		if (empty($this->collection_object)) {
			Throw new \Exception('You must provide collection object!');
		}
		$options = [
			'flag_delete_row' => $this->process_submit[self::BUTTON_SUBMIT_DELETE] ?? false,
			'skip_type_validation' => true,
			'skip_optimistic_lock' => $this->options['skip_optimistic_lock'] ?? false,
			'form_class' => $this->form_class,
			'max_records' => $this->misc_settings['max_records'] ?? [],
		];
		// we do not need to reload values from database because we locked them
		if ($this->values_loaded) {
			$options['original'] = $this->original_values;
		}
		$result = $this->collection_object->merge($this->values, $options);
		if (!$result['success']) {
			if (!empty($result['error'])) {
				foreach ($result['error'] as $v) {
					$this->error('danger', $v);
				}
			}
			// show warnings
			if (!empty($result['warning'])) {
				foreach ($result['warning'] as $v) {
					$this->error('warning', $v);
				}
			}
			$this->rollback = true;
			return false;
		} else { // if success
			// show warnings
			if (!empty($result['warning'])) {
				foreach ($result['warning'] as $v) {
					$this->error('warning', $v);
				}
			}
			// success messages
			if (!empty($result['deleted'])) { // deleted
				$this->values_deleted = true;
			} else if ($result['inserted']) { // inseted
				$this->values_inserted = true;
				// we must put serial columns back into values
				if (!empty($result['new_serials'])) {
					$this->new_serials = $result['new_serials'];
					$this->values = array_merge_hard($this->values, $result['new_serials']);
					$this->loadPk($this->values);
				}
			} else if (!empty($result['updated'])) { // updated
				$this->values_updated = true;
				// merge updated pk
				$this->pk = array_merge_hard($this->pk, $result['new_pk']);
			} else { // if no update/insert/delete we rollback
				$this->values_no_changes = true;
				return false;
			}
			return true;
		}
	}
1118382
public function save()
    {
        $data = $this->getData();
        if ($this->_collection->save($data, ["j" => true])['err'] === null) {
            $this->_id = $data['_id'];
            $this->_cache->store(static::getCollection()."_{$this->_id}", $data);
            return true;
        }
        // @codeCoverageIgnoreStart
        return false;
        // @codeCoverageIgnoreEnd
    }
1147816
private function createCollection($title, $key, $locale, $userId, $parent = null, $id = null)
    {
        $data = [
            'title' => $title,
            'key' => $key,
            'type' => ['id' => 2],
            'locale' => $locale,
        ];

        if (null !== $parent) {
            $data['parent'] = $parent;
        }

        if (null !== $id) {
            $data['id'] = $id;
        }

        return $this->collectionManager->save($data, $userId);
    }
120077
public function save()
    {
        $oVendor = oxNew(\OxidEsales\Eshop\Core\Model\BaseModel::class);
        $oVendor->init('oxvendor');
        if ($oVendor->load($this->getEditObjectId())) {
            $sShowSuffixField = 'oxvendor__oxshowsuffix';
            $blShowSuffixParameter = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('blShowSuffix');
            $oVendor->$sShowSuffixField = new \OxidEsales\Eshop\Core\Field((int) $blShowSuffixParameter);
            $oVendor->save();
        }

        return parent::save();
    }