Conversation
|
Great submission! I think I want to discuss the whole dynamic part a little more, but I think this has great benefit to the platform. Just want to think through some of the workflows a bit more, to support it easier. |
| /// <returns></returns> | ||
| public async Task<BlazorDbEvent> AddSchemaAsync(StoreSchema storeSchema) | ||
| { | ||
| if (!_dbStore.Dynamic) |
|
|
||
| stores[schema.name] = def; | ||
| } | ||
| if (dbStore.dynamic) { |
There was a problem hiding this comment.
I don't think belongs in createDb. Shouldn't it be handled in C# or in the addSchema function?
| db.open().then(_ => { | ||
| db.open().then(db => { | ||
| if (dbStore.dynamic) | ||
| window.blazorDB.databases.find(d => d.name === dbStore.name).db = db; |
There was a problem hiding this comment.
Doesn't this already happen on L113/L114?
|
|
||
| async Task BuildNewDynamic(string dbName) | ||
| { | ||
| var newDbStore = new DbStore() { Name = dbName, StoreSchemas = new List<StoreSchema>(), Version = 0, Dynamic = true }; |
There was a problem hiding this comment.
Rather than open the DB here and have your logic in the javascript version to get around the Dexie bug, should we not allowed a DB to be opened if there is no schema? What's the point to open it anyway?
Thinking out loud, maybe in AddSchema we detect if any previous schemas and then open after at least 1 schema is added?
This starts to address #9. If a manager is requested, but the database name does not exist, it will create a new dynamic database; then, store schema must be defined for it before database can receive data.
DbStoreclass now has a property to distinguish dynamic versus static databases. Behavior of static databases and methods for operating on them should not be affected by this PR.