I've been using liteDB to store some values. However i tried setting up a 2. db to save some different values and those ones do not persist between application restarts. Embeds does persist. General settings do not. I have no idea why this happens or where the difference is. During the session i can save and read the values without any problems but after restarting values are lost.
string botToken = "SOMEVALUE";
DBhelper.addGeneralSetting(botToken);
public DataBaseHelper()
{
db = new LiteDatabase(@"Embeds.db");
// Get collection
collection = db.GetCollection<ServerEmbed>("Embeds");
// Create unique index in MessageID field
collection.EnsureIndex(x => x.MessageID, true);
settingDb = new LiteDatabase(@"GeneralSettings.db");
generalSettings = settingDb.GetCollection<GeneralSetting>("GeneralSettings");
generalSettings.EnsureIndex(x=> x.Setting, true);
}
public void addToDatabase(ServerEmbed embed)
{
collection.Insert(embed);
}
public void addGeneralSetting(GeneralSetting setting)
{
generalSettings.Insert(setting);
}
public class GeneralSetting
{
[BsonField("Setting")]
public string Setting { get; set; }
[BsonField("Value")]
public object Value { get; set; }
public GeneralSetting(string setting, object value)
{
Setting = setting;
Value = value;
}
public GeneralSetting() { }
public override string ToString()
{
return $"Key: {Setting} + Value {Value.ToString()}";
}
}