forked from jsnbuchanan/crowd-funder-for-time-pwa
start adding the SQL approach to files, also using the Dexie approach if desired
This commit is contained in:
@@ -209,12 +209,8 @@ When converting from Dexie.js to SQL-based implementation, follow these patterns
|
||||
```
|
||||
|
||||
Key Considerations:
|
||||
1. Always use parameterized queries to prevent SQL injection
|
||||
2. Use the `generateUpdateStatement` helper for update operations
|
||||
3. Use the `mapColumnsToValues` helper for processing query results
|
||||
4. Handle transactions explicitly for batch operations
|
||||
5. Use appropriate error handling with the StorageError class
|
||||
6. Consider platform-specific capabilities when implementing features
|
||||
- Use the `generateUpdateStatement` helper for update operations
|
||||
- Use the `mapColumnsToValues` helper for processing query results
|
||||
|
||||
Example Migration:
|
||||
```typescript
|
||||
@@ -238,7 +234,12 @@ export async function updateSettings(settings: Settings): Promise<void> {
|
||||
|
||||
Remember to:
|
||||
- Create database access code to use the platform service, putting it in front of the Dexie version
|
||||
- Instead of removing Dexie-specific code, keep it; if we use the results of the query, then check the USE_DEXIE_DB from app.ts and if it's true then use that instead of the SQL code.
|
||||
- Instead of removing Dexie-specific code, keep it.
|
||||
|
||||
- For creates & updates & deletes, the duplicate code is fine.
|
||||
|
||||
- For queries where we use the results, make the setting from SQL into a 'let' variable, then wrap the Dexie code in a check for USE_DEXIE_DB from app.ts and if it's true then use that result instead of the SQL code's result.
|
||||
|
||||
- Test thoroughly after migration
|
||||
- Consider data migration needs, and warn if there are any potential migration problems
|
||||
|
||||
|
||||
Reference in New Issue
Block a user