Implement data persistence
18-F-cali opened this issue · comments
We could we json as data structure and store it in files ?
Maybe use a sqlite database?
Maybe use a sqlite database?
we are trying to keep it as simple as possible so would prolly be best avoiding sql. i think startin with json is great, or something like MongoDb or even LiteDb
Maybe use a sqlite database?
we are trying to keep it as simple as possible so would prolly be best avoiding sql. i think startin with json is great, or something like MongoDb or even LiteDb
Oh yup, in that case I think Mongo is a good idea.
No idea how to work with databases
how about we do file persistence first and then db persistence ?
Would probably be more work to roll your own file reading and loading than just wiring up entity framework with mongodb
Cool, Will check it out then.
Any recommendation to learn more about it?
Cool, Will check it out then.
Any recommendation to learn more about it?
Mongodb has free courses on their site. Kniw tim corey also has 1 about it
MongoDb does not actually support EF directly. But I still think Mongo even on it's own is a good option.
Here's a document that can help someone get started: https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mongo-app?view=aspnetcore-5.0&tabs=visual-studio
If this isn't worked out, can maybe have a call sometime this week and run through it.
As discussed lets use liteDB
while going through docs I found litedb does not support Datetimeoffset:
but Stack overflowsuggets to convert store the time as a timestamp which is a long. So store DateTimeOffset.ToUnixTimeSeconds() when you store the data and DateTimeOffset.FromUnixTimeSeconds() when you retrieve it.
And I didn't fully understand the second suggestion.
There is also this suggestion
mapper.RegisterType<DateTime>(
value => value.ToString("o", CultureInfo.InvariantCulture),
bson => DateTime.ParseExact(bson, "o", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind));
mapper.RegisterType<DateTimeOffset>(
value => value.ToString("o", CultureInfo.InvariantCulture),
bson => DateTimeOffset.ParseExact(bson, "o", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind));
using (var db = new LiteDatabase("instance.db", mapper))
{
...
}