-
Notifications
You must be signed in to change notification settings - Fork 0
Document
The Document keyword defines the configuration of the Document object in a table. This is the element that most of all represents the concept of "document" as it is intended in a MongoDB database.
Its identity fields are:
-
label (optional): this attribute accepts a string. It contains the string that is going to be displayed as a title to the query result;
-
table (required): this attribute accepts a string. It contains the name of the MongoDB database Collection to which the query is going to make reference while gathering the content of the Document;
-
sortby (optional): this attribute accepts a string. It contains the name of the MongoDB database column that the query will use as a reference to sort the result;
-
order (optional): this attribute accepts a string with value
"asc"o"desc". It's the type of order for the sortby parameter: -
"asc"means that the order will be ascending (this is also the default value); -
"desc"means that the order will be descending. -
query (optional): this attribute accepts a JSON object. It contains the parameters and the values on which to execute the query.
Its body fields are:
-
row (optional): It corresponds to the information of a row in the Document. It's composed by the fields described below
- name (required): it's the name of the MongoDB document's column;
- label (optional): it's an alternative name for the document's column;
-
type (required): It contains the type of the data contained in the row. Possible types are:
-
Array: an array of elements;
-
Object: a JSON object;
-
Link: a link to a specific resource
link( label: <text to show> ) -
Image: an image file
image( height: <pixels> width: <pixels> ) -
String: a simple string;
-
Number: a simple number.
-
-
action (optional): It contains the actions that can be invoked from the Document. It's composed by the fields described below
-
Export (optional): it's the action that exports the data structure of the Document. Possible values are
json,csv,true,false; -
SendEmail (optional): it's the action that sends an email containing the data structure of the Document. Possible values are
json,csv,true,false.
-
Export (optional): it's the action that exports the data structure of the Document. Possible values are
The following code shows an example of Document.
Document (
table: 'users',
label: 'Users',
sortby: 'surname',
order: 'asc',
query: {age : { $lt : 40}}
) {
row(
name: 'surname',
label: 'Surname',
type: 'string'
)
row(
name: 'name',
label: 'Name',
type: 'string'
)
row(
name: 'orders',
label: 'Orders',
type: 'number',
transformation: function(val) { return val.length; }
)
}