{"id":3580,"url":"https://github.com/nitrite/nitrite-java","last_synced_at":"2026-01-07T00:03:40.214Z","repository":{"id":37854762,"uuid":"88777477","full_name":"nitrite/nitrite-java","owner":"nitrite","description":"NoSQL embedded document store for Java","archived":false,"fork":false,"pushed_at":"2025-07-07T19:12:34.000Z","size":5516,"stargazers_count":868,"open_issues_count":5,"forks_count":97,"subscribers_count":26,"default_branch":"main","last_synced_at":"2025-07-07T23:35:58.938Z","etag":null,"topics":["android","database","documentdb","embedded-database","mobile-database","nosql","object-database","object-storage"],"latest_commit_sha":null,"homepage":"https://bit.ly/no2db","language":"Java","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":"CHANGELOG.md","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},"funding":{"github":"anidotnet"}},"created_at":"2017-04-19T18:26:54.000Z","updated_at":"2025-07-05T03:16:00.000Z","dependencies_parsed_at":"2024-01-01T18:30:57.632Z","dependency_job_id":"ee3c6f31-a23d-492e-b92a-f49270c2c5bc","html_url":"https://github.com/nitrite/nitrite-java","commit_stats":{"total_commits":930,"total_committers":21,"mean_commits":"44.285714285714285","dds":0.5311827956989248,"last_synced_commit":"4e746bee4e4500a5da58f8ca6d317a8d2ebcc42b"},"previous_names":["dizitart/nitrite-database"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/nitrite/nitrite-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrite%2Fnitrite-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrite%2Fnitrite-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrite%2Fnitrite-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrite%2Fnitrite-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nitrite","download_url":"https://codeload.github.com/nitrite/nitrite-java/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrite%2Fnitrite-java/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264324674,"owners_count":23590934,"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":["android","database","documentdb","embedded-database","mobile-database","nosql","object-database","object-storage"],"created_at":"2024-01-05T20:16:45.505Z","updated_at":"2026-01-07T00:03:40.183Z","avatar_url":"https://github.com/nitrite.png","language":"Java","funding_links":["https://github.com/sponsors/anidotnet"],"categories":["Libraries","数据库"],"sub_categories":["Database"],"readme":"# Nitrite Database\n\n[![Build](https://github.com/nitrite/nitrite-java/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/nitrite/nitrite-java/actions/workflows/build.yml)\n[![CodeQL](https://github.com/nitrite/nitrite-java/actions/workflows/codeql-analysis.yml/badge.svg?branch=main)](https://github.com/nitrite/nitrite-java/actions/workflows/codeql-analysis.yml)\n[![codecov](https://codecov.io/gh/nitrite/nitrite-java/branch/main/graph/badge.svg)](https://codecov.io/gh/nitrite/nitrite-java)\n[![javadoc](https://javadoc.io/badge2/org.dizitart/nitrite/javadoc.svg)](https://javadoc.io/doc/org.dizitart/nitrite) \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 - mvstore, rocksdb\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- Android compatibility (API Level 26)\n\n## Kotlin Extension\n\nNitrite has a kotlin extension called **Potassium Nitrite** for kotlin developers.\nVisit [here](https://github.com/nitrite/nitrite-java/tree/main/potassium-nitrite) for more details.\n\n## Flutter Version\n\nIf you are looking for Nitrite for Flutter/Dart, head over to [nitrite-flutter](https://github.com/nitrite/nitrite-flutter).\n\n## Deprecation Notice\n\nNitrite DataGate and Nitrite Explorer is now deprecated and no longer maintained.\n\n## Getting Started with Nitrite\n\n**NOTE:** There are breaking api changes in version 4.x. So please read the [guide](https://nitrite.dizitart.com/java-sdk/getting-started/index.html) before upgrading from 3.x.x.\n\n### How To Install\n\nTo use Nitrite in any Java application, first add the nitrite bill of materials, then add required dependencies:\n\n**Maven**\n\n```xml\n\u003cdependencyManagement\u003e\n    \u003cdependencies\u003e\n        \u003cdependency\u003e\n            \u003cgroupId\u003eorg.dizitart\u003c/groupId\u003e\n            \u003cartifactId\u003enitrite-bom\u003c/artifactId\u003e\n            \u003cversion\u003e[latest version]\u003c/version\u003e\n            \u003cscope\u003eimport\u003c/scope\u003e\n            \u003ctype\u003epom\u003c/type\u003e\n        \u003c/dependency\u003e\n    \u003c/dependencies\u003e\n\u003c/dependencyManagement\u003e\n\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.dizitart\u003c/groupId\u003e\n        \u003cartifactId\u003enitrite\u003c/artifactId\u003e\n    \u003c/dependency\u003e\n\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.dizitart\u003c/groupId\u003e\n        \u003cartifactId\u003enitrite-mvstore-adapter\u003c/artifactId\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n    \n**Gradle**\n\n```groovy\n\nimplementation(platform(\"org.dizitart:nitrite-bom:[latest version]\"))\n    \nimplementation 'org.dizitart:nitrite'\nimplementation 'org.dizitart:nitrite-mvstore-adapter'\n\n```\n    \n## Examples\n\nA Todo android application is available [here](https://github.com/nitrite/nitrite-android-demo) to demonstrate the usage of Nitrite in android.\n\n### Quick Examples\n\n**Initialize Database**\n\n```java\n// create a mvstore backed storage module\nMVStoreModule storeModule = MVStoreModule.withConfig()\n    .filePath(\"/tmp/test.db\") \n    .compress(true)\n    .build();\n\n// or a rocksdb based storage module\nRocksDBModule storeModule = RocksDBModule.withConfig()\n    .filePath(\"/tmp/test.db\")\n    .build();\n\n\n// initialization using builder\nNitrite db = Nitrite.builder()\n        .loadModule(storeModule)\n        .loadModule(new JacksonMapperModule())  // optional\n        .openOrCreate(\"user\", \"password\");\n\n```\n\n**Create a Collection**\n\n```java\n// Create a Nitrite Collection\nNitriteCollection collection = db.getCollection(\"test\");\n\n// Create an Object Repository\nObjectRepository\u003cEmployee\u003e repository = db.getRepository(Employee.class);\n\n```\n\n**Annotations for POJO**\n\n```java\n\n@Entity(value = \"retired-employee\",     // entity name (optional), \n    indices = {\n        @Index(value = \"firstName\", type = IndexType.NON_UNIQUE),\n        @Index(value = \"lastName\", type = IndexType.NON_UNIQUE),\n        @Index(value = \"note\", type = IndexType.FULL_TEXT),\n})\npublic class Employee implements Serializable {\n    // provides id field to uniquely identify an object inside an ObjectRepository\n    @Id\n    private long empId;\n    private Date joinDate;\n    private String firstName;\n    private String lastName;\n    private String note;\n\n    // ... public getters and setters\n}\n\n```\n\n\n**CRUD Operations**\n\n```java\n\n// create a document to populate data\nDocument doc = Document.createDocument(\"firstName\", \"John\")\n     .put(\"lastName\", \"Doe\")\n     .put(\"birthDay\", new Date())\n     .put(\"data\", new byte[] {1, 2, 3})\n     .put(\"fruits\", new ArrayList\u003cString\u003e() {{ add(\"apple\"); add(\"orange\"); add(\"banana\"); }})\n     .put(\"note\", \"a quick brown fox jump over the lazy dog\");\n\n// insert the document\ncollection.insert(doc);\n\n// find a document\ncollection.find(where(\"firstName\").eq(\"John\").and(where(\"lastName\").eq(\"Doe\"));\n\n// update the document\ncollection.update(where(\"firstName\").eq(\"John\"), createDocument(\"lastName\", \"Wick\"));\n\n// remove the document\ncollection.remove(doc);\n\n// insert an object in repository\nEmployee emp = new Employee();\nemp.setEmpId(124589);\nemp.setFirstName(\"John\");\nemp.setLastName(\"Doe\");\n\nrepository.insert(emp);\n\n```\n\n**Create Indices**\n\n```java\n\n// create document index\ncollection.createIndex(indexOptions(IndexType.NON_UNIQUE), \"firstName\", \"lastName\"); // compound index\ncollection.createIndex(indexOptions(IndexType.FULL_TEXT), \"note\"); // full-text index\n\n// create object index. It can also be provided via annotation\nrepository.createIndex(indexOptions(IndexType.NON_UNIQUE), \"firstName\");\n\n```\n\n**Query a Collection**\n\n```java\n\nDocumentCursor cursor = collection.find(\n    where(\"firstName\").eq(\"John\")               // firstName == John\n    .and(\n        where(\"data\").elemMatch(\"$\".lt(4))      // AND elements of data array is less than 4\n            .and(\n                where(\"note\").text(\"quick\")     // AND note field contains string 'quick' using full-text index\n        )       \n    )\n);\n\nfor (Document document : cursor) {\n    // process the document\n}\n\n// get document by id\nDocument document = collection.getById(nitriteId);\n\n// query an object repository and create the first result\nCursor\u003cEmployee\u003e cursor = repository.find(where(\"firstName\").eq(\"John\"));\nEmployee employee = cursor.firstOrNull();\n\n```\n\n**Transaction**\n\n```java\ntry (Session session = db.createSession()) {\n    try (Transaction transaction = session.beginTransaction()) {\n        NitriteCollection txCol = transaction.getCollection(\"test\");\n\n        Document document = createDocument(\"firstName\", \"John\");\n        txCol.insert(document);\n\n        transaction.commit();\n    } catch (TransactionException e) {\n        transaction.rollback();\n    }\n}\n\n\n```\n\n**Schema Migration**\n\n```java\n\nMigration migration1 = new Migration(Constants.INITIAL_SCHEMA_VERSION, 2) {\n    @Override\n    public void migrate(InstructionSet instructions) {\n        instructions.forDatabase()\n            // make a non-secure db to secure db\n            .addUser(\"test-user\", \"test-password\");\n\n        // create instructions for existing repository\n        instructions.forRepository(OldClass.class, \"demo1\")\n\n            // rename the repository (in case of entity name changes)\n            .renameRepository(\"migrated\", null)\n\n            // change datatype of field empId from String to Long and convert the values\n            .changeDataType(\"empId\", (TypeConverter\u003cString, Long\u003e) Long::parseLong)\n\n            // change id field from uuid to empId\n            .changeIdField(Fields.withNames(\"uuid\"), Fields.withNames(\"empId\"))\n\n            // delete uuid field\n            .deleteField(\"uuid\")\n    \n            // rename field from lastName to familyName\n            .renameField(\"lastName\", \"familyName\")\n\n            // add new field fullName and add default value as - firstName + \" \" + lastName\n            .addField(\"fullName\", document -\u003e document.get(\"firstName\", String.class) + \" \"\n                + document.get(\"familyName\", String.class))\n\n            // drop index on firstName\n            .dropIndex(\"firstName\")\n\n            // drop index on embedded field literature.text\n            .dropIndex(\"literature.text\")\n\n            // change data type of embedded field from float to integer and convert the values \n            .changeDataType(\"literature.ratings\", (TypeConverter\u003cFloat, Integer\u003e) Math::round);\n    }\n};\n\nMigration migration2 = new Migration(2, 3) {\n    @Override\n    public void migrate(InstructionSet instructions) {\n        instructions.forCollection(\"test\")\n            .addField(\"fullName\", \"Dummy Name\");\n    }\n};\n\nMVStoreModule storeModule = MVStoreModule.withConfig()\n    .filePath(\"/temp/employee.db\")\n    .compressHigh(true)\n    .build();\n\ndb = Nitrite.builder()\n    .loadModule(storeModule)\n    \n    // schema versioning is must for migration\n    .schemaVersion(2)\n\n    // add defined migration paths\n    .addMigrations(migration1, migration2)\n    .openOrCreate();\n\n```\n\n**Import/Export Data**\n\n```java\n// Export data to json file\n\n// create export options\nExportOptions exportOptions = new ExportOptions();\n// set the nitrite factory\nexportOptions.setNitriteFactory(() -\u003e openDb(\"test.db\"));\n// set the collections to export\nexportOptions.setCollections(List.of(\"first\"));\n// set the repositories to export\nexportOptions.setRepositories(List.of(\"org.dizitart.no2.support.data.Employee\", \"org.dizitart.no2.support.data.Company\"));\n// set the keyed repositories to export\nexportOptions.setKeyedRepositories(Map.of(\"key\", Set.of(\"org.dizitart.no2.support.data.Employee\")));\n// create an exporter with export options\nExporter exporter = Exporter.withOptions(exportOptions);\nexporter.exportTo(\"test.json\");\n\n// Import data from the file\n\n// create import options\nImportOptions importOptions = new ImportOptions();\n// set the nitrite factory\nimportOptions.setNitriteFactory(() -\u003e openDb(\"new-test.db\"));\n// create an importer with import options\nImporter importer = Importer.withOptions(importOptions);\nimporter.importFrom(\"test.json\");\n\n```\n\nMore details are available in the [guide](https://nitrite.dizitart.com/java-sdk/getting-started/index.html).\n\n## Release Notes\n\nRelease notes are available [here](https://github.com/nitrite/nitrite-java/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/java-sdk/getting-started/index.html\"\u003eDocument\u003c/a\u003e\u003c/p\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cp\u003e\u003ca href=\"https://javadoc.io/doc/org.dizitart/nitrite\"\u003eJavaDoc\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, ensure you have JDK 11 (or higher) and Maven 3 installed.\n\n```shell script\n\ngit clone https://github.com/nitrite/nitrite-java.git\ncd nitrite-java\nmvn clean install\n\n```\n\n## Support / Feedback\n\nFor issues with, questions about, or feedback create a [discussion](https://github.com/orgs/nitrite/discussions).\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-java/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## Contributors\n\nThis project exists thanks to all the people who contribute. For more details please visit [CONTRIBUTING.md](https://github.com/nitrite/nitrite-java/blob/main/CONTRIBUTING.md).\n\n## Sponsors\n\nSupport this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor](https://github.com/sponsors/anidotnet) for this project.\n\n## Presentation \u0026 Talks\n\n[Idan Sheinberg](https://github.com/sheinbergon) has given a talk on Nitrite at [**Kotlin Everywhere - TLV Edition**](https://www.meetup.com/KotlinTLV/events/265145254/) meetup on October 27, 2019. Please find his presentation [here](https://www.slideshare.net/IdanShinberg/nitrite-choosing-the-rite-embedded-database).\n\n## Special Thanks\n\n\u003cdiv\u003e\n\u003ca href=\"https://www.ej-technologies.com/products/jprofiler/overview.html\" style=\"margin-right: 20px;\"\u003e\n    \u003cimg src=\"https://www.ej-technologies.com/images/product_banners/jprofiler_medium.png\" alt=\"JProfiler\"/\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://www.yourkit.com/\" style=\"margin-right: 20px;\"\u003e\n    \u003cimg src=\"https://www.yourkit.com/images/yklogo.png\" alt=\"YourKit\"/\u003e\n\u003c/a\u003e\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\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitrite%2Fnitrite-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnitrite%2Fnitrite-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitrite%2Fnitrite-java/lists"}