---
name: "bson_iter_codewscope"
section: "3"
platform: "linux"
package: "libbson-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/bson_iter_codewscope"
---

# bson\_iter\_codewscope(3)

## SYNOPSIS

```
#define BSON_ITER_HOLDS_CODEWSCOPE(iter) \
   (bson_iter_type ((iter)) == BSON_TYPE_CODEWSCOPE)
const char *
bson_iter_codewscope (const bson_iter_t *iter,
                      uint32_t *length,
                      uint32_t *scope_len,
                      const uint8_t **scope);
```

## PARAMETERS

- •

  **iter**: A *bson\_iter\_t*.

- •

  **length**: An optional location for the length of the resulting UTF-8 encoded string.

- •

  **scope\_len**: A optional location for the length of **scope**.

- •

  **scope**: An optional location to store the immutable raw scope BSON document.

## DESCRIPTION

The **bson\_iter\_codewscope()** function acts similar to *bson\_iter\_code()* except for BSON\_TYPE\_CODEWSCOPE elements. It also will provide a pointer to the buffer for scope, which can be loaded into a *bson\_t* using *bson\_init\_static()*.

## RETURNS

An UTF-8 encoded string containing the JavaScript code which should not be modified or freed.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
