Closed ktaze1 closed 4 years ago
Hi @ktaze1 , if you use something like SQLite with default (typical) settings, the data will generally be stored in a per-use location. This is true on iOS and Android because on those devices everything is per-user. If it's a desktop app for macOS or Windows, the data will be stored wherever the SQLite connection string says the .db3
file is located. The sample use a path such as this:
var dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MyStore.db3");
var database = new SQLiteAsyncConnection(dbPath);
So that location is already user-dependent.
In Mobile Blazor Bindings it doesn't matter whether it's a Hybrid App, Native App, or anything else, because all the code is running locally as the user's identity.
The only thing is that if you want to share logic between a Blazor Web app and a Blazor Native/Hybrid app then you'll want to create an intermediate layer via services.
I apologize in advance since this was asked in #105 but it has been awhile and I couldn't understand fully back in asked issue.
Let's say there is an app where there are multiple users. So we better store users' information in a database. In Blazor WebAssembly, we add service to
Startup.cs
asservices.AddDbContext<DatabaseNameContext>();
and define the API Controller in the Server project and Client project can access to this API with HttpClient (therefore there is no access to database directly, i assume).So in BlazorHybrid/MobileBlazorBindings there is this TodoApp sample which uses Sqlite. But doesn't it mean that changes in one user doesn't effect other -since it's local-? @Eilon said back in #105 that one good way is "Have an intermediate layer (middle tier) for connecting to the database ". So, in order to this do we need to add another project to our solution for handling this requests? I would assume this newly added project kinda works like the Server project in Blazor WASM. Continuing from same approach can we say
-
BlazorWASMApp.Client
=HybridApp
,HybridApp.Android
,HybridApp.iOS
-BlazorWASMApp.Server
(?) =HybridApp.DataAccessLayer
or this is simply wrong?
Is there any other pattern for remote access to a database?