---
name: "Mango::Protocol"
section: "3pm"
platform: "linux"
package: "libmango-perl"
version: "1.30-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Mango::Protocol"
---

# Mango::Protocol(3pm)

The MongoDB wire protocol

## NAME

Mango::Protocol - The MongoDB wire protocol

## SYNOPSIS

```
  use Mango::Protocol;
  my $protocol = Mango::Protocol->new;
  my $bytes    = $protocol->query(1, 'foo', {}, 0, 10, {}, {});
```

## DESCRIPTION

Mango::Protocol is a minimalistic implementation of the MongoDB wire protocol.

## METHODS

Mango::Protocol inherits all methods from Mojo::Base and implements the following new ones.

### build\_get\_more

```
  my $bytes = $protocol->build_get_more($id, $name, $return, $cursor);
```

Build message for `"GET_MORE"` operation.

### build\_kill\_cursors

```
  my $bytes = $protocol->build_kill_cursors($id, @ids);
```

Build message for `"KILL_CURSORS"` operation.

### build\_query

```
  my $bytes = $protocol->build_query($id, $name, $flags, $skip, $return,
    $query, $fields);
```

Build message for `"QUERY"` operation.

### command\_error

```
  my $err = $protocol->command_error($doc);
```

Check document for command error.

### next\_id

```
  my $id = $protocol->next_id(23);
```

Generate next id.

### parse\_reply

```
  my $reply = $protocol->parse_reply(\$str);
```

Extract and parse `"reply"` message.

### query\_failure

```
  my $err = $protocol->query_failure($reply);
```

Check reply for query failure.

### write\_error

```
  my $err = $protocol->write_error($doc);
```

Check document for write error.

## SEE ALSO

Mango, Mojolicious::Guides, \<http://mojolicio.us\>.
