DME
Data model extension contributions are created using the Business NXT DME Admin tool. This tools allows you to:
- Create new contributions defining new tables, columns, relations, indexes and more.
- Import an existing contribution.
- Apply a contribution to a customer (which means it is applied to all the companies of that customer).
All data model extensions can be accessed through the GraphQL API using the GraphQL extensions schema. There are several things to keep in mind when working with DMEs in GraphQL:
- Tables, columns, and relations are referenced by their indentifier (and not by model numbers).
- Identifiers specified as strings (such as in
column : "myExtColumn", orname : "myExtTable") are case-insensitive. - The actual identifier of a table, column, or relation is composed from the contribution short name and the entities identifier. For instance, if a new table has the identifier
myExtTableand the contribution short name isMyDme, then the actual table identifier isMyDme_myExtTable.
The following snippet shows an example:
query read_dme_table($cid : Int)
{
useCompany(no: $cid)
{
table(name : "mydme_myExtTable")
{
items
{
MyDme_pk : integerValue
MyDme_description : stringValue
MyDme_createdTimestamp : timestampValue
}
}
}
}If you do not want to have fields prefixed with the contribution short name in the result JSON, you can use aliases without the prefix but specify the full column identifier in the optional name argument, as shown in the following snippet:
query read_dme_table($cid : Int)
{
useCompany(no: $cid)
{
table(name : "mydme_myexttable")
{
items
{
pk : integerValue(name : "MyDme_pk")
description : stringValue(name : "MyDme_description")
createdTimestamp : timestampValue(name : "MyDme_createdTimestamp")
}
}
}
}Note that the casing of the identifiers in the previous examples varies to demonstrate that the identifiers are case-insensitive.
For input types (such as in filters or values arguments) the column names and values are specified with separate fields, as previously described. Here is an example:
mutation create_reviews($cid :Int!, $pno : String!, $r1 : Int!, $r2 : Int!)
{
useCompany(no : $cid)
{
table_update(
name : "MyDme_ProductReview",
filters : [
{
_and : [
{
column : "MyDme_ProductNo",
stringValue : {_eq : $pno}
},
{
column : "MyDme_ReviewNo",
integerValue : {_eq : $r1}
}
]
}
],
values : [
[
{
column : "MyDme_Description",
stringValue : "A good product!"
}
]
])
{
affectedRows
items
{
MyDme_ProductNo : stringValue
MyDme_ReviewNo : integerValue
MyDme_Description : stringValue
}
}
}
}