-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic databases and store schema #10
base: master
Are you sure you want to change the base?
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why just for dynamic?
@@ -32,6 +106,9 @@ window.blazorDB = { | |||
|
|||
stores[schema.name] = def; | |||
} | |||
if (dbStore.dynamic) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
DbStore
class 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.