public function add(array $data) {

        try {

            $document = (new Visitor($data))->toArray();

            $this->collection->insert($document, ['w' => true]);

            return new \MongoId($document['_id']);
        }
        catch (\MongoCursorException $e) {
            throw new MongoMapperException($e->getMessage());
        }
        catch (\MongoException $e) {
            throw new MongoMapperException($e->getMessage());
        }
    }
public function add(array $data) {

        try {

            $document = (new Visitor($data))->toArray();

            $this->collection->insert($document, ['w' => true]);

            return new \MongoId($document['_id']);
        }
        catch (\MongoCursorException $e) {
            throw new MongoMapperException($e->getMessage());
        }
        catch (\MongoException $e) {
            throw new MongoMapperException($e->getMessage());
        }
    }
public function add ( array $ data ) { try { $ document = ( new Visitor ( $ data ) ) -> toArray ( ) ; $ this -> collection -> insert ( $ document , [ 'w' => true ] ) ; return new \ MongoId ( $ document [ '_id' ] ) ; } catch ( \ MongoCursorException $ e ) { throw new MongoMapperException ( $ e -> getMessage ( ) ) ; } catch ( \ MongoException $ e ) { throw new MongoMapperException ( $ e -> getMessage ( ) ) ; } }
Add records to collection

@param array $data
@throws \Sonar\Exceptions\MongoMapperException
@return \MongoId
Add records to collection