First release of `drift_sqflite`

This commit is contained in:
Simon Binder 2022-03-14 21:51:43 +01:00
parent ece91869f6
commit f3b945564f
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
4 changed files with 73 additions and 0 deletions

10
drift_sqflite/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
.DS_Store
.dart_tool/
.packages
.pub/
build/
ios/.generated/
ios/Flutter/Generated.xcconfig
ios/Runner/GeneratedPluginRegistrant.*

View File

@ -0,0 +1,3 @@
## 1.0.0
- Initial release, replacing the `moor_flutter` package.

21
drift_sqflite/LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 Simon Binder
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

39
drift_sqflite/README.md Normal file
View File

@ -0,0 +1,39 @@
## drift_sqflite
`drift_sqflite` contains a drift database implementation based on the `sqflite`
package.
For more information on `drift`, see its [documentation](https://drift.simonbinder.eu/docs/).
### Usage
The `SqfliteQueryExecutor` class can be passed to the constructor of your drift database
class to make it use `sqflite`.
```dart
@DriftDatabase(tables: [Todos, Categories])
class MyDatabase extends _$MyDatabase {
// we tell the database where to store the data with this constructor
MyDatabase() : super(_openConnection());
// you should bump this number whenever you change or add a table definition.
// Migrations are covered later in the documentation.
@override
int get schemaVersion => 1;
}
QueryExecutor _openConnection() {
return SqfliteQueryExecutor.inDatabaseFolder(path: 'db.sqlite');
}
```
__Note__: The `drift_sqflite` package is an alternative to the standard approach suggested in
the drift documentation (which consists of a `NativeDatabase` instead of `SqfliteQueryExecutor`).
Using this package is primarily recommended when migrating existing projects off `moor_flutter`.
When using a `SqfliteQueryExecutor`, you don't need to depend on `sqlite3_flutter_libs` like the
drift documentation suggests for the standard approach.
### Migrating from `moor_flutter`
The easiest way to migrate from `moor_flutter` to `drift_sqflite` is to use the
[automatic migration tool](https://drift.simonbinder.eu/name/#automatic-migration).