Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
anidotnet committed Jan 2, 2024
2 parents bd70584 + 0990ae1 commit d981831
Show file tree
Hide file tree
Showing 88 changed files with 1,187 additions and 778 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:

name: Build with Java ${{ matrix.java }} in Ubuntu
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
Expand Down Expand Up @@ -89,9 +89,9 @@ jobs:

name: Build with Java ${{ matrix.java }} in MacOS
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
Expand All @@ -112,9 +112,9 @@ jobs:

name: Build with Java ${{ matrix.java }} in Windows
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -54,4 +54,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
90 changes: 53 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![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)
[![codecov](https://codecov.io/gh/nitrite/nitrite-java/branch/main/graph/badge.svg)](https://codecov.io/gh/nitrite/nitrite-java)
![Javadocs](https://javadoc.io/badge/org.dizitart/nitrite.svg)
[![Discussion](https://img.shields.io/badge/chat-Discussion-blueviolet)](https://github.com/nitrite/nitrite-java/discussions)
[![Discussion](https://img.shields.io/badge/chat-Discussion-blueviolet)](https://github.com/orgs/nitrite/discussions)

<p align="center">
<img src="assets/nitrite-logo.svg" width="256" alt="nitrite logo">
Expand All @@ -17,16 +17,18 @@ Nitrite is an embedded database ideal for desktop, mobile or small web applicati

**It features**:

- Schemaless document collection and object repository
- In-memory / file-based store
- Pluggable storage engines - mvstore, rocksdb
- Transaction support
- Schema migration
- Simple Index
- Compound Index
- Full text search
- Very fast, lightweight and fluent API
- Android compatibility (API Level 24)
- Embedded, serverless
- Simple API
- Document-oriented
- Schemaless document collection and object repository
- Extensible storage engines - mvstore, rocksdb
- Indexing and full-text search
- Simple query api
- In-memory and file-based store
- Transaction support
- Schema migration support
- Encryption support
- Android compatibility (API Level 24)

## Kotlin Extension

Expand All @@ -43,13 +45,11 @@ Nitrite DataGate and Nitrite Explorer is now deprecated and no longer maintained

## Getting Started with Nitrite

**NOTE:** There are breaking api changes in version 4.x. So please exercise caution when upgrading from 3.x.x
especially for **package name changes**.
**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.

### How To Install

To use Nitrite in any Java application, first add the nitrite bill of materials,
then add required dependencies:
To use Nitrite in any Java application, first add the nitrite bill of materials, then add required dependencies:

**Maven**

Expand Down Expand Up @@ -79,7 +79,6 @@ then add required dependencies:
</dependencies>
```


**Gradle**

```groovy
Expand Down Expand Up @@ -137,9 +136,9 @@ ObjectRepository<Employee> repository = db.getRepository(Employee.class);

@Entity(value = "retired-employee", // entity name (optional),
indices = {
@Index(value = "firstName", type = IndexType.NonUnique),
@Index(value = "lastName", type = IndexType.NonUnique),
@Index(value = "note", type = IndexType.Fulltext),
@Index(value = "firstName", type = IndexType.NON_UNIQUE),
@Index(value = "lastName", type = IndexType.NON_UNIQUE),
@Index(value = "note", type = IndexType.FULL_TEXT),
})
public class Employee implements Serializable {
// provides id field to uniquely identify an object inside an ObjectRepository
Expand All @@ -161,7 +160,7 @@ public class Employee implements Serializable {
```java

// create a document to populate data
Document doc = createDocument("firstName", "John")
Document doc = Document.createDocument("firstName", "John")
.put("lastName", "Doe")
.put("birthDay", new Date())
.put("data", new byte[] {1, 2, 3})
Expand Down Expand Up @@ -195,11 +194,11 @@ repository.insert(emp);
```java

// create document index
collection.createIndex(indexOptions(IndexType.NonUnique), "firstName", "lastName"); // compound index
collection.createIndex(indexOptions(IndexType.Fulltext), "note"); // full-text index
collection.createIndex(indexOptions(IndexType.NON_UNIQUE), "firstName", "lastName"); // compound index
collection.createIndex(indexOptions(IndexType.FULL_TEXT), "note"); // full-text index

// create object index. It can also be provided via annotation
repository.createIndex(indexOptions(IndexType.NonUnique), "firstName");
repository.createIndex(indexOptions(IndexType.NON_UNIQUE), "firstName");

```

Expand Down Expand Up @@ -234,8 +233,7 @@ Employee employee = cursor.firstOrNull();

```java
try (Session session = db.createSession()) {
Transaction transaction = session.beginTransaction();
try {
try (Transaction transaction = session.beginTransaction()) {
NitriteCollection txCol = transaction.getCollection("test");

Document document = createDocument("firstName", "John");
Expand All @@ -259,10 +257,10 @@ Migration migration1 = new Migration(Constants.INITIAL_SCHEMA_VERSION, 2) {
public void migrate(InstructionSet instructions) {
instructions.forDatabase()
// make a non-secure db to secure db
.addPassword("test-user", "test-password");
.addUser("test-user", "test-password");

// create instructions for existing repository
instructions.forRepository(OldClass.class, null)
instructions.forRepository(OldClass.class, "demo1")

// rename the repository (in case of entity name changes)
.renameRepository("migrated", null)
Expand Down Expand Up @@ -322,17 +320,35 @@ db = Nitrite.builder()
**Import/Export Data**

```java
// Export data to a file
Exporter exporter = Exporter.of(db);
exporter.exportTo(schemaFile);

//Import data from the file
Importer importer = Importer.of(db);
importer.importFrom(schemaFile);
// Export data to json file

// create export options
ExportOptions exportOptions = new ExportOptions();
// set the nitrite factory
exportOptions.setNitriteFactory(() -> openDb("test.db"));
// set the collections to export
exportOptions.setCollections(List.of("first"));
// set the repositories to export
exportOptions.setRepositories(List.of("org.dizitart.no2.support.data.Employee", "org.dizitart.no2.support.data.Company"));
// set the keyed repositories to export
exportOptions.setKeyedRepositories(Map.of("key", Set.of("org.dizitart.no2.support.data.Employee")));
// create an exporter with export options
Exporter exporter = Exporter.withOptions(exportOptions);
exporter.exportTo("test.json");

// Import data from the file

// create import options
ImportOptions importOptions = new ImportOptions();
// set the nitrite factory
importOptions.setNitriteFactory(() -> openDb("new-test.db"));
// create an importer with import options
Importer importer = Importer.withOptions(importOptions);
importer.importFrom("test.json");

```

More details are available in the reference document.
More details are available in the [guide](https://nitrite.dizitart.com/java-sdk/getting-started/index.html).

## Release Notes

Expand All @@ -353,7 +369,7 @@ Release notes are available [here](https://github.com/nitrite/nitrite-java/relea
</thead>
<tbody>
<tr class="odd">
<td><p><a href="https://www.dizitart.org/nitrite-database">Document</a></p></td>
<td><p><a href="https://nitrite.dizitart.com/java-sdk/getting-started/index.html">Document</a></p></td>
<td><p><a href="https://javadoc.io/doc/org.dizitart/nitrite">JavaDoc</a></p></td>
</tr>
</tbody>
Expand All @@ -373,7 +389,7 @@ mvn clean install

## Support / Feedback

For issues with, questions about, or feedback create a [discussion](https://github.com/nitrite/nitrite-java/discussions).
For issues with, questions about, or feedback create a [discussion](https://github.com/orgs/nitrite/discussions).

## Bugs / Feature Requests

Expand Down
1 change: 0 additions & 1 deletion nitrite-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

<name>Nitrite BOM</name>
<description>Nitrite Bill of Materials</description>
<url>https://github.com/nitrite/nitrite-java</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
4 changes: 2 additions & 2 deletions nitrite-jackson-mapper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<artifactId>nitrite-jackson-mapper</artifactId>
<packaging>jar</packaging>

<name>nitrite-jackson-mapper</name>
<url>https://maven.apache.org</url>
<name>Nitrite Jackson Mapper</name>
<description>A NitriteMapper implementation based on Jackson</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void testRepositoryMigrate() {
@Override
public void migrate(InstructionSet instruction) {
instruction.forDatabase()
.addPassword("test-user", "test-password");
.addUser("test-user", "test-password");

instruction.forRepository(OldClass.class, "demo1")
.renameRepository("new", null)
Expand Down Expand Up @@ -154,7 +154,7 @@ public void testCollectionMigrate() {
@Override
public void migrate(InstructionSet instruction) {
instruction.forDatabase()
.addPassword("test-user", "test-password");
.addUser("test-user", "test-password");

instruction.forCollection("test")
.rename("testCollectionMigrate")
Expand Down
Loading

0 comments on commit d981831

Please sign in to comment.