-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
131 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
# WatermelonDB Roadmap | ||
|
||
## From today to 1.0 | ||
Despite being called 0.xx, WatermelonDB is essentially feature-complete and relatively API stable. It's used in production by [Nozbe Teams](https://nozbe.com) and many others. | ||
|
||
WatermelonDB is currently in active development at [Nozbe](https://nozbe.com) for use in advanced projects. It's mostly feature-complete. However, there are a few features left before we can call it 1.0. | ||
|
||
### v0.xxx | ||
|
||
- Full transactionality (atomicity) support ??? | ||
- Field sanitizers | ||
- Optimized tree deleting | ||
- API improvements | ||
We don't call it 1.0 mostly out of convenience, to allow rapid development without incrementing `major` version counter (as dictated by SemVer). We do intend to call WatermelonDB a 1.0 once we can reach a long-term stable API. | ||
|
||
### v1.0 | ||
|
||
Everything above plus having at least one non-trivial app using WatermelonDB in production to verify its concepts | ||
- Optimized tree deleting | ||
- Long term stable API | ||
|
||
### Beyond 1.0 | ||
|
||
- Replace `withObservables` HOC and Prefetching with a solution based on React 17 Suspense feature | ||
- Query templates | ||
- Full transactionality (atomicity) support? | ||
- Field sanitizers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# Set up your app for WatermelonDB | ||
|
||
Make sure you [installed Watermelon](./Installation.md) before proceeding. | ||
|
||
Create `model/schema.js` in your project. You'll need it for [the next step](./Schema.md). | ||
|
||
```js | ||
import { appSchema, tableSchema } from '@nozbe/watermelondb' | ||
|
||
export default appSchema({ | ||
version: 1, | ||
tables: [ | ||
// tableSchemas go here... | ||
] | ||
}) | ||
``` | ||
|
||
Similarly, create `model/migrations.js`. ([More information about migrations](./Advanced/Migrations.md)): | ||
|
||
```js | ||
import { schemaMigrations } from '@nozbe/watermelondb/Schema/migrations' | ||
|
||
export default schemaMigrations({ | ||
migrations: [ | ||
// We'll add migration definitions here later | ||
], | ||
}) | ||
``` | ||
|
||
Now, in your `index.js`: | ||
|
||
```js | ||
import { Database } from '@nozbe/watermelondb' | ||
import SQLiteAdapter from '@nozbe/watermelondb/adapters/sqlite' | ||
|
||
import schema from './model/schema' | ||
import migrations from './model/migrations' | ||
// import Post from './model/Post' // ⬅️ You'll import your Models here | ||
|
||
// First, create the adapter to the underlying database: | ||
const adapter = new SQLiteAdapter({ | ||
schema, | ||
// (You might want to comment it out for development purposes -- see Migrations documentation) | ||
migrations, | ||
// (optional database name or file system path) | ||
// dbName: 'myapp', | ||
// (recommended option, only works on iOS currently) | ||
experimentalUseJSI: true, | ||
// (optional, but you should implement this method) | ||
onSetUpError: error => { | ||
// Database failed to load -- offer the user to reload the app or log out | ||
} | ||
}) | ||
|
||
// Then, make a Watermelon database from it! | ||
const database = new Database({ | ||
adapter, | ||
modelClasses: [ | ||
// Post, // ⬅️ You'll add Models to Watermelon here | ||
], | ||
actionsEnabled: true, | ||
}) | ||
``` | ||
|
||
The above will work on React Native (iOS/Android) and NodeJS. For the web, instead of `SQLiteAdapter` use `LokiJSAdapter`: | ||
|
||
```js | ||
import LokiJSAdapter from '@nozbe/watermelondb/adapters/lokijs' | ||
|
||
const adapter = new LokiJSAdapter({ | ||
schema, | ||
// (You might want to comment it out for development purposes -- see Migrations documentation) | ||
migrations, | ||
useWebWorker: false, | ||
useIncrementalIndexedDB: true, | ||
// dbName: 'myapp', // optional db name | ||
// Optional, but recommended event handlers: | ||
onIndexedDBVersionChange: () => { | ||
// database was deleted in another browser tab (user logged out), so we must make sure we delete | ||
// it in this tab as well | ||
if (checkIfUserIsLoggedIn()) { | ||
window.location.reload() | ||
} | ||
}, | ||
// (optional, but recommended) | ||
onQuotaExceededError: (error) => { | ||
// Browser ran out of disk space -- do something about it | ||
}, | ||
onSetUpError: (error) => { | ||
// Database failed to load -- offer the user to reload the app or log out | ||
}, | ||
extraIncrementalIDBOptions: { | ||
onDidOverwrite: () => { | ||
// Called when this adapter is forced to overwrite contents of IndexedDB. | ||
// This happens if there's another open tab of the same app that's making changes. | ||
// You might use it as an opportunity to alert user to the potential loss of data | ||
} | ||
} | ||
}) | ||
|
||
// The rest is the same! | ||
``` | ||
|
||
* * * | ||
|
||
## Next steps | ||
|
||
➡️ After Watermelon is installed, [**define your app's schema**](./Schema.md) |