{"id":17238339,"url":"https://github.com/hoc081098/sqlbrite","last_synced_at":"2025-08-20T14:31:26.983Z","repository":{"id":34851534,"uuid":"181147960","full_name":"hoc081098/sqlbrite","owner":"hoc081098","description":"🌼 RxDart Reactive stream sqflite(sqlite) for Flutter - Sqlbrite for flutter - A lightweight wrapper around sqflite which introduces reactive stream semantics to SQL operations. https://pub.dev/packages/sqlbrite","archived":false,"fork":false,"pushed_at":"2024-12-02T20:13:02.000Z","size":380,"stargazers_count":30,"open_issues_count":12,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-09T20:22:09.968Z","etag":null,"topics":["flutter","flutter-reactive-sqflite","flutter-reactive-storage","flutter-sqflite","flutter-sqlbrite","flutter-sqlite","rxdart","rxdart-bloc","rxdart-epic","rxdart-ext","rxdart-extensions","rxdart-flutter","rxdart-helper","rxdart-redux","sqlbrite","sqlbrite-dbflow","sqlbrite-rxjava","sqlbrite-sample"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/sqlbrite","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hoc081098.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["hoc081098"],"custom":["https://www.buymeacoffee.com/hoc081098"]}},"created_at":"2019-04-13T09:19:53.000Z","updated_at":"2024-11-06T22:33:40.000Z","dependencies_parsed_at":"2023-12-07T20:25:03.648Z","dependency_job_id":"b9246444-a4d4-4119-978a-ff6ce19088be","html_url":"https://github.com/hoc081098/sqlbrite","commit_stats":{"total_commits":83,"total_committers":4,"mean_commits":20.75,"dds":"0.12048192771084343","last_synced_commit":"b4586e34997ef51582513092dec3047a604dd815"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoc081098%2Fsqlbrite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoc081098%2Fsqlbrite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoc081098%2Fsqlbrite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoc081098%2Fsqlbrite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hoc081098","download_url":"https://codeload.github.com/hoc081098/sqlbrite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230431100,"owners_count":18224655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flutter","flutter-reactive-sqflite","flutter-reactive-storage","flutter-sqflite","flutter-sqlbrite","flutter-sqlite","rxdart","rxdart-bloc","rxdart-epic","rxdart-ext","rxdart-extensions","rxdart-flutter","rxdart-helper","rxdart-redux","sqlbrite","sqlbrite-dbflow","sqlbrite-rxjava","sqlbrite-sample"],"created_at":"2024-10-15T05:45:17.418Z","updated_at":"2024-12-19T12:09:52.790Z","avatar_url":"https://github.com/hoc081098.png","language":"Dart","readme":"# SQL Brite ![alt text](https://avatars3.githubusercontent.com/u/6407041?s=32\u0026v=4)\n\n## Author: [Petrus Nguyễn Thái Học](https://github.com/hoc081098)\n\n[![Tests](https://github.com/hoc081098/sqlbrite/actions/workflows/flutter.yml/badge.svg)](https://github.com/hoc081098/sqlbrite/actions/workflows/flutter.yml)\n[![Build example](https://github.com/hoc081098/sqlbrite/actions/workflows/build-example.yml/badge.svg)](https://github.com/hoc081098/sqlbrite/actions/workflows/build-example.yml)\n[![Pub](https://img.shields.io/pub/v/sqlbrite)](https://pub.dev/packages/sqlbrite)\n[![Pub](https://img.shields.io/pub/v/sqlbrite?include_prereleases)](https://pub.dev/packages/sqlbrite)\n[![Build Status](https://travis-ci.com/hoc081098/sqlbrite.svg?branch=master)](https://travis-ci.com/hoc081098/sqlbrite)\n[![codecov](https://codecov.io/gh/hoc081098/sqlbrite/branch/master/graph/badge.svg)](https://codecov.io/gh/hoc081098/sqlbrite)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Style](https://img.shields.io/badge/style-pedantic-40c4ff.svg)](https://github.com/dart-lang/pedantic)\n[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fhoc081098%2Fsqlbrite\u0026count_bg=%2379C83D\u0026title_bg=%23555555\u0026icon=\u0026icon_color=%23E7E7E7\u0026title=hits\u0026edge_flat=false)](https://hits.seeyoufarm.com)\n\n-   Reactive stream wrapper around `sqflite` for Flutter inspired by [sqlbrite](https://github.com/square/sqlbrite)\n-   Streaming sqflite\n-   RxDart reactive stream sqflite for Flutter\n-   A lightweight wrapper around sqflite which introduces reactive stream semantics to SQL operations.\n\n## Getting Started\n\n1. Depend on it: In your flutter project, add the dependency to your `pubspec.yaml`\n\n```yaml\ndependencies:\n  ...\n  sqlbrite: \u003clatest_version\u003e\n```\n\n2.  Install it: You can install packages from the command line with Flutter:\n\n```shell script\n$ flutter packages get\n```\n\n3. Import it: Now in your Dart code, you can use:\n\n```dart\nimport 'package:sqlbrite/sqlbrite.dart';\n```\n\n## Usage\n\n### 1. Wrap your database in a `BriteDatabase`:\n\n```dart\nfinal Database db = await openDb();\nfinal briteDb = BriteDatabase(db);\nfinal briteDb = BriteDatabase(db, logger: null); // disable logging.\n```\n\n### 2. Using\n\n-   The `BriteDatabase.createQuery` method is similar to `Database.query`. Listen to the returned `Stream\u003cQuery\u003e` which will immediately notify with a `Query` to run.\n-   These queries will run once to get the current data, then again whenever the given table is modified though the `BriteDatabase`.\n\n#### Create entity model\n```dart\nclass Entity {\n  factory Entity.fromJson(Map\u003cString, dynamic\u003e map) { ... }\n  \n  factory Entity.empty() { ... }\n\n  Map\u003cString, dynamic\u003e toJson() { ... }\n}\n```\n\n#### Use `mapToOne` extension method on `Stream\u003cQuery\u003e`\n```dart\n// Emits a single row, emit error if the row doesn't exist or more than 1 row in result set.\nfinal Stream\u003cEntity\u003e singleQuery$ = briteDb.createQuery(\n  'table',\n  where: 'id = ?',\n  whereArgs: [id],\n  limit: 1,\n).mapToOne((row) =\u003e Entity.fromJson(row));\n```\n\n#### Use `mapToOneOrDefault` extension method on `Stream\u003cQuery\u003e`\n```dart\n// Emits a single row, or the given default value if the row doesn't exist, or emit error if more than 1 row in result set\nfinal Stream\u003cEntity\u003e singleOrDefaultQuery$ = briteDb.createQuery(\n  'table',\n  where: 'id = ?',\n  whereArgs: [id],\n  limit: 1,\n).mapToOneOrDefault(\n  (row) =\u003e Entity.fromJson(row),\n  defaultValue: Entity.empty()\n);\n```\n\n#### Use `mapToList` extension method on `Stream\u003cQuery\u003e`\n```dart\n// Emits a list of rows.\nfinal Stream\u003cList\u003cEntity\u003e\u003e listQuery$ = briteDb.createQuery(\n  'table',\n  where: 'name LIKE ?',\n  whereArgs: [queryName],\n).mapToList((row) =\u003e Entity.fromJson(row));\n```\n\n#### Same API like `Database`\n\n```dart\n\n// will trigger query stream again\nbriteDb.insert(\n  'table',\n  Entity(...).toJson()\n);\n\n// will trigger query stream again\nbriteDb.update(\n  'table',\n  Entity(...).toJson(),\n  where: 'id = ?',\n  whereArgs: [id],\n);\n\n// will trigger query stream again\nbriteDb.update(\n  'table',\n  where: 'id = ?',\n  whereArgs: [id],\n);\n\n```\n\n#### Full power of `RxDart` operators\n-   You can use RxDart operators to control the frequency of notifications to subscribers.\n-   The full power of RxDart's operators are available for combining, filtering, and triggering any number of queries and data changes.\n\n```dart\nbriteDb\n    .createQuery(\n      'table',\n      where: 'name LIKE ?',\n      whereArgs: [queryName],\n    )\n    .debounceTime(const Duration(milliseconds: 500))\n    .where(filterQuery) // query is lazy, this lets you not even execute it if you don't need to\n    .mapToList((row) =\u003e Entity.fromJson(row))\n    .listen(updateUI);\n```\n\n## Philosophy\n\nSQL Brite's only responsibility is to be a mechanism for coordinating and composing the notification\nof updates to tables such that you can update queries as soon as data changes.\n\nThis library is not an ORM. It is not a type-safe query mechanism. It's not going to perform database migrations for you.\n\n## License\n    MIT License\n    Copyright (c) 2019 - 2022 Petrus Nguyễn Thái Học\n","funding_links":["https://github.com/sponsors/hoc081098","https://www.buymeacoffee.com/hoc081098"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoc081098%2Fsqlbrite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoc081098%2Fsqlbrite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoc081098%2Fsqlbrite/lists"}