Hey Jasmine, I’m not sure I understand what you’re trying to accomplish. Let me show you what I did as an example and then you can let me know how it deviates from your intended results.
I create a table called parents. It has 2 fields, id (auto increment int) and name (varchar(64)).
I then created a table called children. It has 3 fields, id (auto increment int), parentid (foreign key constrained to parents.id), and name (varchar(64)).
Here is the schema dump from DreamFactory:
{
"name": "parents",
"label": "Parents",
"plural": "Parents",
"primary_key": "id",
"name_field": null,
"field": [
{
"name": "id",
"label": "id",
"type": "id",
"db_type": "int(11)",
"length": 11,
"precision": 11,
"scale": 0,
"default": null,
"required": false,
"allow_null": false,
"fixed_length": false,
"supports_multibyte": false,
"auto_increment": true,
"is_primary_key": true,
"is_foreign_key": false,
"ref_table": "",
"ref_fields": "",
"validation": null,
"value": []
},
{
"name": "name",
"label": "name",
"type": "text",
"db_type": "text",
"length": 0,
"precision": 0,
"scale": 0,
"default": null,
"required": false,
"allow_null": true,
"fixed_length": false,
"supports_multibyte": false,
"auto_increment": false,
"is_primary_key": false,
"is_foreign_key": false,
"ref_table": "",
"ref_fields": "",
"validation": null,
"value": []
}
],
"related": [
{
"name": "childrens_by_parentid",
"type": "has_many",
"ref_table": "children",
"ref_field": "parentid",
"field": "id"
}
],
"access": [
"GET",
"POST",
"PUT",
"PATCH",
"MERGE",
"DELETE"
]
}
{
"name": "children",
"label": "Children",
"plural": "Childrens",
"primary_key": "id",
"name_field": null,
"field": [
{
"name": "id",
"label": "id",
"type": "id",
"db_type": "int(11)",
"length": 11,
"precision": 11,
"scale": 0,
"default": null,
"required": false,
"allow_null": false,
"fixed_length": false,
"supports_multibyte": false,
"auto_increment": true,
"is_primary_key": true,
"is_foreign_key": false,
"ref_table": "",
"ref_fields": "",
"validation": null,
"value": []
},
{
"name": "parentid",
"label": "parentid",
"type": "reference",
"db_type": "int(11)",
"length": 11,
"precision": 11,
"scale": 0,
"default": null,
"required": true,
"allow_null": false,
"fixed_length": false,
"supports_multibyte": false,
"auto_increment": false,
"is_primary_key": false,
"is_foreign_key": true,
"ref_table": "parents",
"ref_fields": "id",
"validation": null,
"value": []
},
{
"name": "name",
"label": "name",
"type": "string",
"db_type": "varchar(64)",
"length": 64,
"precision": 64,
"scale": 0,
"default": null,
"required": true,
"allow_null": false,
"fixed_length": false,
"supports_multibyte": false,
"auto_increment": false,
"is_primary_key": false,
"is_foreign_key": false,
"ref_table": "",
"ref_fields": "",
"validation": null,
"value": []
}
],
"related": [
{
"name": "parents_by_parentid",
"type": "belongs_to",
"ref_table": "parents",
"ref_field": "id",
"field": "parentid"
}
],
"access": [
"GET",
"POST",
"PUT",
"PATCH",
"MERGE",
"DELETE"
]
}
I have a record of a parent named Bob. Bob has two children named Bill and Barney. When I do a GET on his record (record 2,) this is the result
GET http://dsp/rest/db/parents/2?related=*
{
"id": 2,
"name": "Bob",
"childrens_by_parentid": [
{
"id": 3,
"parentid": 2,
"name": "Bill"
},
{
"id": 4,
"parentid": 2,
"name": "Barney"
}
]
}