Example 2 - Simple "Posts" App
This is a simple representative schema for a PostgreSQL datasource, which has 4 objects (tables) - links, posts, topics, users - with relationships between these objects.
Neurelo Schema
{
"objects": {
"links": {
"properties": {
"id": {
"type": "integer",
"default": {
"function": "autoincrement"
},
"identifier": true
},
"link": {
"type": "string",
"sourceType": [
"VarChar",
500
],
"nullable": true
},
"title": {
"type": "string",
"sourceType": [
"VarChar",
500
],
"nullable": true
},
"topic_id": {
"type": "integer",
"nullable": true
},
"topics": {
"nullable": true,
"$ref": "#/objects/topics",
"relation": {
"attrKey": [
"topic_id"
],
"foreignAttrKey": [
"id"
],
"onUpdate": "NoAction",
"onDelete": "NoAction"
}
}
}
},
"posts": {
"properties": {
"content": {
"type": "string",
"nullable": true
},
"id": {
"type": "integer",
"default": {
"function": "autoincrement"
},
"identifier": true
},
"title": {
"type": "string",
"sourceType": [
"VarChar",
200
],
"nullable": true
},
"user_id": {
"type": "integer",
"nullable": true
},
"users": {
"nullable": true,
"$ref": "#/objects/users",
"relation": {
"attrKey": [
"user_id"
],
"foreignAttrKey": [
"id"
],
"onUpdate": "NoAction",
"onDelete": "NoAction"
}
}
}
},
"topics": {
"properties": {
"description": {
"type": "string",
"nullable": true
},
"id": {
"type": "integer",
"default": {
"function": "autoincrement"
},
"identifier": true
},
"links": {
"type": "array",
"items": {
"$ref": "#/objects/links"
}
},
"title": {
"type": "string",
"sourceType": [
"VarChar",
200
],
"nullable": true
}
}
},
"users": {
"properties": {
"email": {
"type": "string",
"sourceType": [
"VarChar",
200
],
"nullable": true
},
"first_name": {
"type": "string",
"sourceType": [
"VarChar",
100
],
"nullable": true
},
"id": {
"type": "integer",
"default": {
"function": "autoincrement"
},
"identifier": true
},
"last_name": {
"type": "string",
"sourceType": [
"VarChar",
100
],
"nullable": true
},
"password": {
"type": "string",
"sourceType": [
"VarChar",
500
],
"nullable": true
},
"posts": {
"type": "array",
"items": {
"$ref": "#/objects/posts"
}
}
}
}
}
}
Last updated