SYNOPSIS

#include <bson.h>

bool
bson_append_array (bson_t       *bson,
                   const char   *key,
                   int           key_length,
                   const bson_t *array);

bool
bson_append_array_begin (bson_t     *bson,
                         const char *key,
                         int         key_length,
                         bson_t     *child);

bool
bson_append_array_end (bson_t *bson,
                       bson_t *child);

DESCRIPTION

The bson_append_array() function shall append child to bson using the specified key. The type of the field will be an array, but it is the responsibility of the caller to ensure that the keys of child are properly formatted with string keys such as "0", "1", "2" and so forth.

The bson_append_array_begin() function shall begin appending an array field to bson. This allows for incrementally building a sub-array. Doing so will generally yield better performance as you will serialize to a single buffer. When done building the sub-array, the caller MUST call bson_append_array_end().

The bson_append_array_end() function shall complete the appending of an array field started with bson_append_array_begin(). child is invalid after calling this function.

RETURN VALUE

TRUE if the element was appended. Otherwise FALSE.

ERRORS

This function will only return FALSE if there was not enough space to store the element.

SEE ALSO

AUTHORS

This page was written by MongoDB, Inc.