docs/Management/Development and Configuration/Datapack/Database.md
ehrumsey a3b50edf45 vault backup: 2025-03-30 00:43:42
Affected files:
.obsidian/workspace.json
Management/Development and Configuration/Datapack/Database.md
2025-03-30 00:43:42 -05:00

887 B

title draft
Database false

Creating a Schema

@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

{
	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[]
					}
					...
				}
			}
			...
		}
	}
}