public function create($query, array $options = []) {
		$defaults = ['model' => $query->model()];
		$options += $defaults;
		$params = compact('query', 'options');

		return Filters::run($this, __FUNCTION__, $params, function($params) {
			$request = ['type' => 'json'];
			$query = $params['query'];
			$options = $params['options'];
			$data = $query->data();
			$data += ['type' => $options['model']::meta('source')];

			if (isset($data['id'])) {
				return $this->update($query, $options);
			}

			$retry = false;
			do {
				$result = $this->connection->post($this->_config['database'], $data, $request);
				$result = is_string($result) ? json_decode($result, true) : $result;

				$retry = $retry ? !$retry : $this->_autoBuild($result);
			} while ($retry);

			if (isset($result['_id']) || (isset($result['ok']) && $result['ok'] === true)) {
				$result = $this->_format($result, $options);
				$query->entity()->sync($result['id'], $result);
				return true;
			}
			return false;
		});
	}
public function create($query, array $options = []) {
		$defaults = ['model' => $query->model()];
		$options += $defaults;
		$params = compact('query', 'options');

		return Filters::run($this, __FUNCTION__, $params, function($params) {
			$request = ['type' => 'json'];
			$query = $params['query'];
			$options = $params['options'];
			$data = $query->data();
			$data += ['type' => $options['model']::meta('source')];

			if (isset($data['id'])) {
				return $this->update($query, $options);
			}

			$retry = false;
			do {
				$result = $this->connection->post($this->_config['database'], $data, $request);
				$result = is_string($result) ? json_decode($result, true) : $result;

				$retry = $retry ? !$retry : $this->_autoBuild($result);
			} while ($retry);

			if (isset($result['_id']) || (isset($result['ok']) && $result['ok'] === true)) {
				$result = $this->_format($result, $options);
				$query->entity()->sync($result['id'], $result);
				return true;
			}
			return false;
		});
	}
public function create ( $ query , array $ options = [ ] ) { $ defaults = [ 'model' => $ query -> model ( ) ] ; $ options += $ defaults ; $ params = compact ( 'query' , 'options' ) ; return Filters :: run ( $ this , __FUNCTION__ , $ params , function ( $ params ) { $ request = [ 'type' => 'json' ] ; $ query = $ params [ 'query' ] ; $ options = $ params [ 'options' ] ; $ data = $ query -> data ( ) ; $ data += [ 'type' => $ options [ 'model' ] :: meta ( 'source' ) ] ; if ( isset ( $ data [ 'id' ] ) ) { return $ this -> update ( $ query , $ options ) ; } $ retry = false ; do { $ result = $ this -> connection -> post ( $ this -> _config [ 'database' ] , $ data , $ request ) ; $ result = is_string ( $ result ) ? json_decode ( $ result , true ) : $ result ; $ retry = $ retry ? ! $ retry : $ this -> _autoBuild ( $ result ) ; } while ( $ retry ) ; if ( isset ( $ result [ '_id' ] ) || ( isset ( $ result [ 'ok' ] ) && $ result [ 'ok' ] === true ) ) { $ result = $ this -> _format ( $ result , $ options ) ; $ query -> entity ( ) -> sync ( $ result [ 'id' ] , $ result ) ; return true ; } return false ; } ) ; }
Create new document.

@param string $query
@param array $options
@return boolean
@filter
Create new document .