getting started using Dreamfactory, looks great. Using MS SQL as source, having two related views without any primary and foreign keys; how can I make the relationship between the two tables without the possibility to change the schema on the database itself ? Is it possible to make “virtual” primary and foreign keys for Dreamfactory only, Tried to mark a field on the a table in the Dreamfactory admin UI, but it tries to set on the database as well ?
Good timing, this feature is about to come out next week (first on GitHub followed closely by Bitnami packages and Docker Hub). The docs at wiki.dreamfactory.com will explain how it works.
In summary, here’s what’ll be supported next week:
GET using virtual foreign keys across two tables on same db
GET using virtual foreign keys across two tables on different dbs
Aliases for virtual fields and relationships
Virtual fields for db functions like appending two string fields such as concat(field1, field2)
Virtual fields for aggregation by field name – sum, min, max, count, etc.
UPDATE support will not be in the next release but will be added shortly in the next sprint ending Dec 20.
@rajivpereraHere is the wiki link for the documentation. Easiest way, is to go the “Schema” tab on the Admin application of your instance, create a new field for the desired table, select “virtual” for the field type and enter a name and SUM(payamt) part goes in the DB function area near the bottom. Since this is an aggregate function, make sure you select aggregate checkbox. When you make a call needing the aggregate results just do GET /api/v2/<service_name>/_table/<table_name>?field=vcol1.