{"id":32267712,"url":"https://github.com/nitrite/nitrite-flutter","last_synced_at":"2026-06-27T22:00:46.423Z","repository":{"id":114495893,"uuid":"493109845","full_name":"nitrite/nitrite-flutter","owner":"nitrite","description":"NoSQL embedded document store for Flutter","archived":false,"fork":false,"pushed_at":"2026-04-15T05:48:33.000Z","size":2116,"stargazers_count":23,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-15T07:31:35.459Z","etag":null,"topics":["database","documentdb","embedded-database","flutter","mobile-database","nosql","object-database","object-storage"],"latest_commit_sha":null,"homepage":"https://bit.ly/no2db","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nitrite.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"anidotnet"}},"created_at":"2022-05-17T05:38:51.000Z","updated_at":"2026-01-31T19:12:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"fcd690f8-d469-4e0f-b9f3-dcc7707f8a09","html_url":"https://github.com/nitrite/nitrite-flutter","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/nitrite/nitrite-flutter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrite%2Fnitrite-flutter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrite%2Fnitrite-flutter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrite%2Fnitrite-flutter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrite%2Fnitrite-flutter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nitrite","download_url":"https://codeload.github.com/nitrite/nitrite-flutter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrite%2Fnitrite-flutter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34869004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-27T02:00:06.362Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["database","documentdb","embedded-database","flutter","mobile-database","nosql","object-database","object-storage"],"created_at":"2025-10-22T22:02:18.586Z","updated_at":"2026-06-27T22:00:46.416Z","avatar_url":"https://github.com/nitrite.png","language":"Dart","funding_links":["https://github.com/sponsors/anidotnet"],"categories":[],"sub_categories":[],"readme":"# Nitrite Database\n\n[![Build Nitrite](https://github.com/nitrite/nitrite-flutter/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/nitrite/nitrite-flutter/actions/workflows/build.yml)\n[![codecov](https://codecov.io/gh/nitrite/nitrite-flutter/branch/main/graph/badge.svg?token=yqfI3tbHqp)](https://codecov.io/gh/nitrite/nitrite-flutter)\n[![Discussion](https://img.shields.io/badge/chat-Discussion-blueviolet)](https://github.com/orgs/nitrite/discussions)\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"assets/nitrite-logo.svg\" width=\"256\" alt=\"nitrite logo\"\u003e\n\u003c/p\u003e\n\n**NO**sql **O**bject (**NO\u003csub\u003e2\u003c/sub\u003e** a.k.a. Nitrite) database is an open source nosql embedded\ndocument store. It supports both in-memory and file based persistent store.\n\nNitrite is an embedded database ideal for desktop, mobile or small web applications.\n\n**It features**:\n\n-   Embedded, serverless\n-   Simple API\n-   Document-oriented\n-   Schemaless document collection and object repository\n-   Extensible storage engines - hive\n-   Indexing and full-text search\n-   Simple query api\n-   In-memory and file-based store\n-   Transaction support\n-   Schema migration support\n-   Encryption support\n\n## Java Version\n\nIf you are looking for Nitrite for java, head over to [nitrite-java](https://github.com/nitrite/nitrite-java).\n\n## Getting Started with Nitrite\n\n### How To Install\n\nTo use Nitrite in any Flutter application, add the below packages in your project:\n\n```bash\ndart pub add nitrite\ndart pub add nitrite_hive_adapter\n```\n\n## Examples\n\nA Todo flutter application is available [here](https://github.com/nitrite/nitrite-flutter/tree/main/examples/nitrite_demo). It demonstrates the use of nitrite database in a flutter application. It uses nitrite as a database and riverpod for state management.\n\n### Quick Examples\n\n**Initialize Database**\n\n```dart\n// create a hive backed storage module\nvar storeModule = HiveModule.withConfig()\n    .crashRecovery(true)\n    .path('$dbDir/db')\n    .build();\n\n\n// initialization using builder\nvar db = await Nitrite.builder()\n    .loadModule(storeModule)\n    .openOrCreate(username: 'user', password: 'pass123');\n\n```\n\n**Create a Collection/ObjectRepository**\n\n```dart\n// Create a Nitrite Collection\nvar collection = await db.getCollection(\"test\");\n\n// Create an Object Repository\nvar repository = await db.getRepository\u003cBook\u003e();\n\n```\n\n**Code generators for Entity classes**\n\nThe nitrite generator package can automatically generate entity classes from dart classes. It uses [source_gen](https://pub.dev/packages/source_gen) package to generate code. To use the generator, add the following packages to your project:\n\n```bash\ndart pub add nitrite_generator --dev\ndart pub add build_runner --dev\n```\n\nUse below annotations in your dart classes:\n\n```dart\nimport 'package:nitrite/nitrite.dart';\n\npart 'book.no2.dart';\n\n@Convertable(className: 'MyBookConverter')\n@Entity(name: 'books', indices: [\n  Index(fields: ['tags'], type: IndexType.nonUnique),\n  Index(fields: ['description'], type: IndexType.fullText),\n  Index(fields: ['price', 'publisher']),\n])\nclass Book with _$BookEntityMixin {\n  // id field\n  @Id(fieldName: 'book_id', embeddedFields: ['isbn', 'book_name'])\n  @DocumentKey(alias: 'book_id')\n  BookId? bookId;\n\n  String? publisher;\n  double? price;\n  List\u003cString\u003e tags = [];\n  String? description;\n\n  Book([\n    this.bookId,\n    this.publisher,\n    this.price,\n    this.tags = const [],\n    this.description,\n  ]);\n  \n}\n\n// composite id class\n@Convertable()\nclass BookId {\n  String? isbn;\n\n  // set a different field name in the document\n  @DocumentKey(alias: \"book_name\")\n  String? name;\n\n  // ignore the field in the document\n  @IgnoredKey()\n  String? author;\n}\n\n```\n\nAnd run the following command to generate necessary *.no2.dart files:\n\n```bash\ndart run build_runner build\n```\n\n**CRUD Operations**\n\n```dart\n\n// create a document to populate data\nvar doc = createDocument(\"firstName\", \"fn1\")\n    .put(\"lastName\", \"ln1\")\n    .put(\"birthDay\", DateTime.parse(\"2012-07-01T16:02:48.440Z\"))\n    .put(\"data\", [1, 2, 3])\n    .put(\"list\", [\"one\", \"two\", \"three\"])\n    .put(\"body\", \"a quick brown fox jump over the lazy dog\")\n    .put(\"books\", [\n      createDocument(\"name\", \"Book ABCD\").put(\"tag\", [\"tag1\", \"tag2\"]),\n      createDocument(\"name\", \"Book EFGH\").put(\"tag\", [\"tag3\", \"tag1\"]),\n      createDocument(\"name\", \"No Tag\")\n    ]);\n\n// insert the document\nawait collection.insert(doc);\n\n// find documents from the collection\nvar cursor = collection.find(filter: and([\n      where('lastName').eq('ln1'),\n      where(\"firstName\").notEq(\"fn1\"),\n      where(\"list\").eq(\"four\"),\n    ]),\n);\n\n// update the document\nawait collection.update(\n  where('firstName').eq('fn1'),\n  createDocument('firstName', 'fn1-updated'),\n  updateOptions(insertIfAbsent: true),\n);\n\n// remove the document\nawait coll.remove(where('firstName').eq('fn1-updated'));\n\n// insert an object in repository\nvar bookId = BookId();\nbookId.isbn = 'abc123';\nbookId.author = 'xyz';\nbookId.name = 'Book 1';\n\nvar book = Book();\nbook.bookId = bookId;\nbook.tags = ['tag1', 'tag2'];\nbook.description = 'A book about nitrite database';\nbook.publisher = 'rando publisher';\nbook.price = 150.5;\n\nawait repository.insert(book);\n\n```\n\n**Create Indices**\n\n```dart\n\n// create document index\nawait collection.createIndex(['firstName', 'lastName']); // unique index\nawait collection.createIndex(['firstName'], indexOptions(IndexType.nonUnique))\n\n// create object index. It can also be provided via annotation\nawait repository.createIndex(\"publisher\", indexOptions(IndexType.NonUnique));\n\n```\n\n**Query a Collection**\n\n```dart\n\nvar cursor = collection.find(\n  filter: and([\n    where('lastName').eq('ln2'),\n    where(\"firstName\").notEq(\"fn1\"),\n    where(\"list\").eq(\"four\")\n  ]),\n);\n\nawait for (var d in cursor) {\n  print(d);\n}\n\n// get document by a nitrite id\nvar document = await collection.getById(nitriteId);\n\n// query an object repository and create the first result\nvar cursor = repository.find(\n    filter: where('book_id.isbn').eq('abc123'),\n);\nvar book = await cursor.first();\n\n```\n\n\n**Transaction**\n\nNitrite has support for transaction. Transaction is supported only for file based storage.\n\n```dart\nvar session = db.createSession();\nvar tx = await session.beginTransaction();\n\nvar txRepo = await tx.getRepository\u003cBook\u003e();\nawait txRepo.insert(book);\nawait tx.commit();\n\n```\nor, another way to do the same thing:\n\n```dart\nvar session = db.createSession();\nawait session.executeTransaction((tx) async {\n  var txRepo = await tx.getRepository\u003cBook\u003e();\n  await txRepo.insertMany([book1, book2, book3]);\n});\n\n```\n\n**Schema Migration**\n\nNitrite supports schema migration. It can be used to migrate data from one schema version to another. It is useful when you want to change the schema of your application without losing the existing data.\n\n```dart\n\nvar migration = Migration(\n  3,\n  4,\n  (instructionSet) {\n    instructionSet\n        .forCollection('test')\n        .addField('age', defaultValue: 10);\n  },\n);\n\ndb = await Nitrite.builder()\n      .loadModule(storeModule)\n      .schemaVersion(4)\n      .addMigrations([migration])\n      .openOrCreate();\n\n```\n\n\n**Import/Export Data**\n\n```dart\n// Export data to a file\nvar exporter = Exporter.withOptions(\n  dbFactory: () async {\n    var storeModule = HiveModule.withConfig()\n    .crashRecovery(true)\n    .path('$dbDir/old-db')\n    .build();\n\n    return Nitrite.builder()\n    .loadModule(storeModule)\n    .openOrCreate(username: 'user', password: 'pass123');\n  },\n);\nawait exporter.exportTo(exportedPath);\n\n//Import data from the file\nvar importer = Importer.withConfig(\n  dbFactory: () async {\n    var storeModule = HiveModule.withConfig()\n    .crashRecovery(true)\n    .path('$dbDir/new-db')\n    .build();\n\n    return Nitrite.builder()\n    .loadModule(storeModule)\n    .openOrCreate();\n  },\n);\nawait importer.importFrom(exportedPath);\n\n```\n\nMore details are available in the reference document.\n\n## Release Notes\n\nRelease notes are available [here](https://github.com/nitrite/nitrite-flutter/releases).\n\n## Documentation\n\n\u003ctable\u003e\n\u003ccolgroup\u003e\n\u003ccol style=\"width: 50%\" /\u003e\n\u003ccol style=\"width: 50%\" /\u003e\n\u003c/colgroup\u003e\n\u003cthead\u003e\n\u003ctr class=\"header\"\u003e\n\u003cth\u003eReference\u003c/th\u003e\n\u003cth\u003eAPI\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr class=\"odd\"\u003e\n\u003ctd\u003e\u003cp\u003e\u003ca href=\"https://nitrite.dizitart.com/flutter-sdk/getting-started/index.html\"\u003eDocument\u003c/a\u003e\u003c/p\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cp\u003e\u003ca href=\"https://pub.dev/documentation/nitrite/latest\"\u003eAPI Reference\u003c/a\u003e\u003c/p\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n## Build\n\nTo build and test Nitrite, you need to install melos. Melos is a CLI tool to manage Dart projects with multiple packages. It is similar to Lerna for JavaScript/TypeScript projects. Visit [melos](https://melos.invertase.dev/) for more details to setup your system.\n\n\n```shell script\n\nmelos bs\nmelos run test\n\n```\n\n## Bugs / Feature Requests\n\nThink you’ve found a bug? Want to see a new feature in the Nitrite? Please open an issue [here](https://github.com/nitrite/nitrite-flutter/issues). But\nbefore you file an issue please check if it is already existing or not.\n\n## Maintainers\n\n-   Anindya Chatterjee\n\n## Contributing\n\nDo you want to contribute with a PR? PRs are always welcome, just make sure to create a [discussion](https://github.com/nitrite/nitrite-flutter/discussions) first to avoid any unnecessary work.\n\n## Special Thanks\n  \n\u003ca href=\"https://www.macstadium.com/\" style=\"margin-right: 30px;\"\u003e\n    \u003cimg src=\"https://uploads-ssl.webflow.com/5ac3c046c82724970fc60918/5c019d917bba312af7553b49_MacStadium-developerlogo.png\" height=\"32\" alt=\"MacStadium\"/\u003e\n\u003c/a\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitrite%2Fnitrite-flutter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnitrite%2Fnitrite-flutter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitrite%2Fnitrite-flutter/lists"}