.NET Core temporary JSON storage for those times when you want persistent storage without a SQL database, etc.
All you need to use JStore is a Repository
.
using JStore;
var intRepository = new Repository<int>();
And that quickly, you're up and running!
Each repository holds an in-memory list of items. You can access it via the Items
property.
var integers = intRepository.Items;
Because the Items
property is just a List<T>
you can add, remove, and insert items just like normal.
intRepository.Items.Add(10);
Your changes to your item list will not actually be saved to the backing JSON file until you tell the repository to save its item list.
await intRepository.SaveAsync();
If you're using ASP.NET Core and want to inject your repositories, just call services.AddJStore();
in your startup method. Now you can inject any repository you please!
The performance of JStore could be improved. However, since it is not intended to be used as long-term or production storage, I am leaving it as-is for now. It serves its purpose, which is to provide persistent storage for a small data-set when you are in the prototyping stage and just want persistent storage for testing without all the overhead of using, say, a SQL database.