MongoDB Wrappers¶
This page explains the syntax of the command CREATE WRAPPER MONGODB
. Generating this command manually is difficult so if you want to create a MongoDB base view we recommend to use the Administration Tool or Design Studio.
CREATE [ OR REPLACE ] WRAPPER MONGODB <name:identifier>
[ FOLDER = <literal> ]
DATASOURCENAME = <name:identifier>
DATABASE = <literal>
COLLECTION = <literal>
[ LIMITDOCUMENTS = <integer> ]
[ PIPELINE = <literal> ]
[ OUTPUTSCHEMA ( <field> [, <field> ]* ) ]
<field> ::=
<name:identifier> [ = <mapping:literal> ] [ : <type:literal> ]
[ ( { OBL | OPT } ) ]
[ ( DEFAULTVALUE <literal> ) ]
[ EXTERN ]
[ <inline constraints> ]*
| <name:identifier> [ = <mapping:literal> ] : ARRAY OF ( <register field> )
[ ( DEFAULTVALUE <literal> ) ]
[ <inline constraints> ]*
| <name:register field>
<register field> ::=
<name:identifier> [ = <mapping:literal> ] :
REGISTER OF ( <field> [, <field> ]* ) [ <inline constraints> ]*
[ ( DEFAULTVALUE <literal> ) ]
[ <inline constraints> ]*
<inline constraint> ::=
[ NOT ] NULL
| [ NOT ] UPDATEABLE
| { SORTABLE [ ASC | DESC ] | NOT SORTABLE }
To modify an existing MongoDB wrapper, use the statement ALTER WRAPPER MONGODB.
ALTER WRAPPER MONGODB <name:identifier>
[ DATASOURCENAME = <name:identifier> ]
[ DATABASE = <literal> ]
[ COLLECTION = <literal> ]
[ LIMITDOCUMENTS = <integer> ]
[ PIPELINE = <literal> ]
[ OUTPUTSCHEMA ( <field> [, <field> ]* ) ]
<field> ::= (see Syntax of the CREATE WRAPPER MONGODB statement)
The OUTPUTSCHEMA
clause defines the schema of the data that the wrapper will provide (see section Wrapper Metadata).
For each simple-type element the type must be specified. Furthermore, an association may be indicated between the name of the
field returned by the wrapper and the name of the field in MongoDB (as specified in the mapping).
The MongoDB wrapper retrieves information from the documents stored in a MongoDB collection. To do this, it is necessary to
specify the name of the collection (COLLECTION
) and the database (DATABASE
) to which it belongs, as well as the name of
the MongoDB data source (DATASOURCENAME
).
When creating the base view with the Administration Tool or Design Studio, the number of documents to be analyzed to obtain the
wrapper’s schema can be specified using the parameter LIMITDOCUMENTS
. The default value for this parameter is 150 documents, to analyze
all documents in a collection set LIMITDOCUMENTS
value to 0.
Additionally, the parameter PIPELINE
can be used to specify a JSON aggregation pipeline that will be applied to the documents
obtained from the collection. The aggregation pipeline can contain an interpolation string (see section Execution Context of a Query and Interpolation Strings).