1BSON::Code(3)         User Contributed Perl Documentation        BSON::Code(3)
2
3
4

NAME

6       BSON::Code - BSON type wrapper for Javascript code
7

VERSION

9       version v1.12.2
10

SYNOPSIS

12           use BSON::Types ':all';
13
14           $code = bson_code( $javascript );
15           $code = bson_code( $javascript, $scope );
16

DESCRIPTION

18       This module provides a BSON type wrapper for the "Javascript code" type
19       and the "Javascript with Scope" BSON types.
20

ATTRIBUTES

22   code
23       A string containing Javascript code. Defaults to the empty string.
24
25   scope
26       An optional hash reference containing variables in the scope of "code".
27       Defaults to "undef".
28

METHODS

30   length
31       Returns the length of the "code" attribute.
32
33   TO_JSON
34       If the "BSON_EXTJSON" option is true, returns a hashref compatible with
35       MongoDB's extended JSON
36       <https://github.com/mongodb/specifications/blob/master/source/extended-
37       json.rst> format, which represents it as a document as follows:
38
39           {"$code" : "<code>"}
40           {"$code" : "<code>", "$scope" : { ... } }
41
42       If the "BSON_EXTJSON" option is false, an error is thrown, as this
43       value can't otherwise be represented in JSON.
44

AUTHORS

46       •   David Golden <david@mongodb.com>
47
48       •   Stefan G. <minimalist@lavabit.com>
49
51       This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc.
52
53       This is free software, licensed under:
54
55         The Apache License, Version 2.0, January 2004
56
57
58
59perl v5.34.0                      2021-07-22                     BSON::Code(3)
Impressum