diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index 2fe53b0..bb0e8f4 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -97,12 +97,12 @@ "state": { "type": "markdown", "state": { - "file": "Management/Development and Configuration/Datapack/Logging.md", + "file": "Management/Development and Configuration/Datapack/Database.md", "mode": "source", "source": false }, "icon": "lucide-file", - "title": "Logging" + "title": "Database" } } ], @@ -266,8 +266,9 @@ }, "active": "f26c718e97d69090", "lastOpenFiles": [ - "Management/Development and Configuration/Untitled.md", "Management/Development and Configuration/Datapack/Logging.md", + "Management/Development and Configuration/Datapack/Database.md", + "Management/Development and Configuration/Untitled.md", "Management/Development and Configuration/index.md", "Untitled.md", "Management/User and Admin/Crafty Controller.md", diff --git a/Management/Development and Configuration/Datapack/Database.md b/Management/Development and Configuration/Datapack/Database.md new file mode 100644 index 0000000..f877472 --- /dev/null +++ b/Management/Development and Configuration/Datapack/Database.md @@ -0,0 +1,49 @@ +--- +title: Database +draft: "false" +--- +# Creating a Schema +```ts +@add(this.schema) +function tables.myTable() { + createTable(myTable, name); + + createField(myTable, id, int, [pk, un]); + createField(myTable, name, string, [fk, un]); + createField(myTable, description, string, []); + + finishTable(myTable); // Runs checks, such as existence of pk +} +``` +# Data Structure +```json +{ + database: { + tables: { + $table: { + name: string, // $name + fields: string[], // $field + pk: string, // $field + fk: string[], // $field (optional) + un: string[], // $field + rq: string[], // $filed (optional) + data: { + $field: { + name: string, // $field + type: string, // $type + props: { // these are parsed from props array + pk: bool, + fk: bool, + un: bool, + rq: bool, + }, + content: any[] + } + ... + } + } + ... + } + } +} +``` \ No newline at end of file