[gnome-games] database: Add table and factory methods for metadata objects
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] database: Add table and factory methods for metadata objects
- Date: Sun, 26 Aug 2018 19:27:19 +0000 (UTC)
commit 55e4d50d106d04926651c40fb423299b2bb686c5
Author: theawless <theawless gmail com>
Date: Sun Aug 26 07:10:42 2018 +0530
database: Add table and factory methods for metadata objects
These will be used to cache metadata in the database.
src/database/database.vala | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/database/database.vala b/src/database/database.vala
index ee9a54c5..b513df88 100644
--- a/src/database/database.vala
+++ b/src/database/database.vala
@@ -3,7 +3,7 @@
private class Games.Database : Object {
private Sqlite.Database database;
- private const string CREATE_TABLE_QUERY = """
+ private const string CREATE_RESOURCES_TABLE_QUERY = """
CREATE TABLE IF NOT EXISTS game_resources (
id INTEGER PRIMARY KEY NOT NULL,
uri TEXT NOT NULL
@@ -18,6 +18,13 @@ private class Games.Database : Object {
SELECT EXISTS (SELECT 1 FROM game_resources WHERE uri=$URI LIMIT 1);
""";
+ private const string CREATE_METADATA_TABLE_QUERY = """
+ CREATE TABLE IF NOT EXISTS game_metadata (
+ uid TEXT PRIMARY KEY NOT NULL,
+ developer TEXT
+ ) WITHOUT ROWID;
+ """;
+
public Database (string path) throws Error {
if (Sqlite.Database.open (path, out database) != Sqlite.OK)
throw new DatabaseError.COULDNT_OPEN ("Couldn’t open the database for “%s”.", path);
@@ -56,8 +63,17 @@ private class Games.Database : Object {
return new DatabaseUriSource (database);
}
+ public DatabaseUid get_uid (Uid uid) {
+ return new DatabaseUid (database, uid);
+ }
+
+ public DatabaseDeveloper get_developer (Developer developer, Uid uid) {
+ return new DatabaseDeveloper (database, developer, uid);
+ }
+
private void create_tables () throws Error {
- exec (CREATE_TABLE_QUERY, null);
+ exec (CREATE_RESOURCES_TABLE_QUERY, null);
+ exec (CREATE_METADATA_TABLE_QUERY, null);
}
private void exec (string query, Sqlite.Callback? callback) throws Error {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]