Skip to content

Commit

Permalink
Finish missing docs for the rest of the database module.
Browse files Browse the repository at this point in the history
  • Loading branch information
Relintai committed Apr 27, 2024
1 parent bef76e4 commit 3dfa9bd
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 0 deletions.
11 changes: 11 additions & 0 deletions modules/database/doc_classes/Database.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Database" inherits="Reference" version="4.4">
<brief_description>
Represents a database.
</brief_description>
<description>
Represents a database.
Classes inherited from it implement communication with database systems.
See [SQLite3Database] for an example.
Currently only an sqlite backend is available, however communication with other systems (like MySQL, or PostgreSQL) can be implemented without too much hassle using engine modules.
</description>
<tutorials>
<link title="Simple Database Demo Project">https://github.com/Relintai/pandemonium_demo_projects/tree/master/database/database_simple</link>
<link title="Prepared Statement Database Demo Project">https://github.com/Relintai/pandemonium_demo_projects/tree/master/database/prepared_statements</link>
<link title="Web Demo Projects">https://github.com/Relintai/pandemonium_demo_projects/tree/master/web</link>
</tutorials>
<methods>
<method name="get_connection">
<return type="DatabaseConnection" />
<description>
Returns a [DatabaseConnection] object which can be used to run queries on the database.
Always get a new one, don't store it, as the database backend might give different ones depending on certain factors (like calling threads) for faster operation.
</description>
</method>
</methods>
<members>
<member name="connection_string" type="String" setter="set_connection_string" getter="get_connection_string" default="&quot;&quot;">
Connection string used by the backend.
</member>
</members>
<constants>
Expand Down
17 changes: 17 additions & 0 deletions modules/database/doc_classes/DatabaseConnection.xml
Original file line number Diff line number Diff line change
@@ -1,72 +1,89 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="DatabaseConnection" inherits="Reference" version="4.4">
<brief_description>
Represents a connection to a database server.
</brief_description>
<description>
Represents a connection to a database server.
Don't create these directly, use the [code]get_connection()[/code] method in [Database] to get one.
</description>
<tutorials>
</tutorials>
<methods>
<method name="create_prepared_statement">
<return type="PreparedStatement" />
<description>
Creates a [PreparedStatement] for use with this database connection.
</description>
</method>
<method name="database_connect">
<return type="int" enum="Error" />
<argument index="0" name="connection_str" type="String" />
<description>
Connect to the database. The backend will automatically call this.
</description>
</method>
<method name="ensure_version_table_exists">
<return type="void" />
<description>
Ensures that a table that contains the database's verison exists for compatibility checks.
</description>
</method>
<method name="escape">
<return type="String" />
<argument index="0" name="str" type="String" />
<description>
Escapes the given [String] using the database backend's excape method.
Use it on user input for sanitization.
Note that [QueryBuilder] does this where necessary automatically.
Also note that when using [PreparedStatement]s this is not needed.
</description>
</method>
<method name="get_owner">
<return type="Database" />
<description>
Returns the owner [Database].
</description>
</method>
<method name="get_query_builder">
<return type="QueryBuilder" />
<description>
Returns a new [QueryBuilder] that is properly set up for this connection.
</description>
</method>
<method name="get_table_builder">
<return type="TableBuilder" />
<description>
Returns a new [TableBuilder] that is properly set up for this connection.
</description>
</method>
<method name="get_table_version">
<return type="int" />
<argument index="0" name="table" type="String" />
<description>
Returns the current table version. This can be used to determine database compatibility, or for example whether to run migrations or not during startup.
</description>
</method>
<method name="query">
<return type="QueryResult" />
<argument index="0" name="query" type="String" />
<description>
Run a query. Use the resulting[QueryResult] object to read data from the database.
</description>
</method>
<method name="query_run">
<return type="void" />
<argument index="0" name="query" type="String" />
<description>
Run a query.
</description>
</method>
<method name="set_table_version">
<return type="void" />
<argument index="0" name="table" type="String" />
<argument index="1" name="version" type="int" />
<description>
Sets the current table version.
</description>
</method>
</methods>
Expand Down
17 changes: 17 additions & 0 deletions modules/database/doc_classes/DatabaseManager.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="DatabaseManager" inherits="Object" version="4.4">
<brief_description>
Database Manager Singleton.
</brief_description>
<description>
Database Manager Singleton.
Stores database connections that need to be accessible throughout the application.
</description>
<tutorials>
</tutorials>
Expand All @@ -12,32 +15,38 @@
<argument index="0" name="db" type="Database" />
<argument index="1" name="set_as_default" type="bool" default="true" />
<description>
Add a Database. If [code]set_as_default[/code] is true it will be set as default, which means it will be set to the [member ddb] property.
</description>
</method>
<method name="get_database">
<return type="Database" />
<argument index="0" name="index" type="int" />
<description>
Returns a Database.
</description>
</method>
<method name="get_database_count">
<return type="int" />
<description>
Returns how many databases are stored in the singleton.
</description>
</method>
<method name="get_databases">
<return type="Array" />
<description>
Returns all Databases.
</description>
</method>
<method name="initialized">
<return type="void" />
<description>
Calls the [code]initialized[/code] signal.
</description>
</method>
<method name="load">
<return type="void" />
<description>
Not implemented currently. Will likely load databases from ProjectSettings.
</description>
</method>
<method name="migrate">
Expand All @@ -46,45 +55,53 @@
<argument index="1" name="should_seed" type="bool" />
<argument index="2" name="pseed" type="int" />
<description>
Calls the [member migration] signal.
</description>
</method>
<method name="remove_database">
<return type="void" />
<argument index="0" name="index" type="int" />
<argument index="1" name="unset_if_default" type="bool" default="true" />
<description>
Removes a Database.
</description>
</method>
</methods>
<members>
<member name="ddb" type="Database" setter="set_ddb" getter="get_ddb">
The default database.
</member>
</members>
<signals>
<signal name="database_added">
<argument index="0" name="db" type="Database" />
<description>
Emitted when a [Database] is added.
</description>
</signal>
<signal name="database_removed">
<argument index="0" name="db" type="Database" />
<description>
Emitted when a [Database] is removed.
</description>
</signal>
<signal name="default_database_changed">
<argument index="0" name="db" type="Database" />
<description>
Emitted when default database is changed.
</description>
</signal>
<signal name="initialized">
<description>
Can be emitted using the [member initialized] method after the database connections are set up.
</description>
</signal>
<signal name="migration">
<argument index="0" name="clear" type="bool" />
<argument index="1" name="should_seed" type="bool" />
<argument index="2" name="pseed" type="int" />
<description>
Can be emitted using the [member migrate] method when the databse structure needs to be updated (or created).
</description>
</signal>
</signals>
Expand Down
2 changes: 2 additions & 0 deletions modules/database/doc_classes/DatabaseMultiThreaded.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="DatabaseMultiThreaded" inherits="Database" version="4.4">
<brief_description>
Contains helper methods for multi threaded database systems on the c++ side. Don't use it directly.
</brief_description>
<description>
Contains helper methods for multi threaded database systems on the c++ side. Don't use it directly.
</description>
<tutorials>
</tutorials>
Expand Down
2 changes: 2 additions & 0 deletions modules/database/doc_classes/DatabaseSingleThreaded.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="DatabaseSingleThreaded" inherits="Database" version="4.4">
<brief_description>
Contains helper methods for single threaded database systems on the c++ side.
</brief_description>
<description>
Contains helper methods for single threaded database systems on the c++ side.
</description>
<tutorials>
</tutorials>
Expand Down
Loading

0 comments on commit 3dfa9bd

Please sign in to comment.