Commit f04e171b authored by librebob's avatar librebob

Add getMeta and setMeta functions to models.

parent db81a975
from peewee import *
import datetime
from peewee import DoesNotExist
db = SqliteDatabase('store.db')
class BaseModel(Model):
......@@ -13,6 +15,19 @@ class GameRecord(BaseModel):
created_date = DateTimeField(default=datetime.datetime.now)
modified_date = DateTimeField()
class MetaRecord(BaseModel):
key = CharField(unique=True)
value = TextField()
class SettingsRecord(BaseModel):
key = CharField(unique=True)
value = TextField()
def getMeta(key):
try:
return (MetaRecord.get(MetaRecord.key == 'flathub_added')).value
except DoesNotExist:
return None
def setMeta(key, value):
MetaRecord.replace(key=key, value=value).execute()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment