First version
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using SQLite;
|
||||
using cfs_tracker.Models;
|
||||
|
||||
namespace cfs_tracker.Data;
|
||||
|
||||
public class AppDatabase
|
||||
{
|
||||
private SQLiteAsyncConnection? _database;
|
||||
private bool _initialized;
|
||||
|
||||
public async Task InitAsync()
|
||||
{
|
||||
if (_initialized)
|
||||
return;
|
||||
|
||||
var dbPath = Path.Combine(FileSystem.Current.AppDataDirectory, "mecfs_tracker.db3");
|
||||
|
||||
_database = new SQLiteAsyncConnection(dbPath);
|
||||
await _database.CreateTableAsync<HealthEntry>();
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
public SQLiteAsyncConnection Connection =>
|
||||
_database ?? throw new InvalidOperationException("Database not initialized.");
|
||||
}
|
||||
Reference in New Issue
Block a user