Skip to content

Commit

Permalink
feat: Rebrand project to react-native-nitro-sqlite (#81)
Browse files Browse the repository at this point in the history
Co-authored-by: Oskar Kwaśniewski <[email protected]>
  • Loading branch information
chrispader and okwasniewski authored Nov 13, 2024
1 parent f37bc1f commit 66069ab
Show file tree
Hide file tree
Showing 103 changed files with 774 additions and 739 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github: [mrousavy]
github: [mrousavy, chrispader]
2 changes: 1 addition & 1 deletion .github/workflows/build-android-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: example/android/app/build/outputs/apk/release/app-release.apk
asset_name: "QuickSQLiteExample-${{ github.event.release.tag_name }}.apk"
asset_name: "NitroSQLiteExample-${{ github.event.release.tag_name }}.apk"
asset_content_type: application/vnd.android.package-archive

# Gradle cache doesn't like daemons
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ jobs:
run: "set -o pipefail && xcodebuild \
CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ \
-derivedDataPath build -UseModernBuildSystem=YES \
-workspace QuickSQLiteExample.xcworkspace \
-scheme QuickSQLiteExample \
-workspace NitroSQLiteExample.xcworkspace \
-scheme NitroSQLiteExample \
-sdk iphonesimulator \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 16' \
Expand Down Expand Up @@ -114,8 +114,8 @@ jobs:
run: "set -o pipefail && xcodebuild \
CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ \
-derivedDataPath build -UseModernBuildSystem=YES \
-workspace QuickSQLiteExample.xcworkspace \
-scheme QuickSQLiteExample \
-workspace NitroSQLiteExample.xcworkspace \
-scheme NitroSQLiteExample \
-sdk iphonesimulator \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 16' \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint-typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ jobs:
- name: Run ESLint CI in example/
working-directory: example
run: bun lint-ci
- name: Run ESLint CI in react-native-quick-sqlite
- name: Run ESLint CI in react-native-nitro-sqlite
working-directory: package
run: bun lint-ci

- name: Run ESLint with auto-fix in example/
working-directory: example
run: bun lint
- name: Run ESLint with auto-fix in react-native-quick-sqlite
- name: Run ESLint with auto-fix in react-native-nitro-sqlite
working-directory: package
run: bun lint

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ Remember to add tests for your change if possible. Run the unit tests by:
bun test
```

To edit the Objective-C files, open `example/ios/SequelExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-quick-sqlite`.
To edit the Objective-C files, open `example/ios/SequelExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-nitro-sqlite`.

To edit the Kotlin files, open `example/android` in Android studio and find the source files at `rnquicksqlite` under `Android`.
To edit the Kotlin files, open `example/android` in Android studio and find the source files at `rnnitrosqlite` under `Android`.

### Commit message convention

Expand Down
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
![screenshot](https://raw.githubusercontent.com/margelo/react-native-quick-sqlite/main/header2.png)
![screenshot](https://raw.githubusercontent.com/margelo/react-native-nitro-sqlite/main/header2.png)

<div align="center">
<pre align="center">
bun add react-native-quick-sqlite
bun add react-native-nitro-sqlite
npx pod-install</pre>
<a align="center" href="https://github.com/mrousavy?tab=followers">
<img src="https://img.shields.io/github/followers/mrousavy?label=Follow%20%40mrousavy&style=social" />
Expand All @@ -14,7 +14,7 @@
</div>
<br />

Quick SQLite embeds the latest version of SQLite and provides a low-level JSI-backed API to execute SQL queries.
Nitro SQLite embeds the latest version of SQLite and provides a low-level JSI-backed API to execute SQL queries.

Performance metrics are intentionally not presented, [anecdotic testimonies](https://dev.to/craftzdog/a-performant-way-to-use-pouchdb7-on-react-native-in-2022-24ej) suggest anywhere between 2x and 5x speed improvement. On small queries you might not notice a difference with the old bridge but as you send large data to JS the speed increase is considerable.

Expand All @@ -25,7 +25,7 @@ TypeORM is officially supported, however, there is currently a parsing issue wit
## API

```typescript
import {open} from 'react-native-quick-sqlite'
import {open} from 'react-native-nitro-sqlite'

const db = open('myDb.sqlite')

Expand Down Expand Up @@ -54,7 +54,7 @@ db = {
The basic query is **synchronous**, it will block rendering on large operations, further below you will find async versions.

```typescript
import { open } from 'react-native-quick-sqlite';
import { open } from 'react-native-nitro-sqlite';

try {
const db = open('myDb.sqlite');
Expand Down Expand Up @@ -83,7 +83,7 @@ Throwing an error inside the callback will ROLLBACK the transaction.
If you want to execute a large set of commands as fast as possible you should use the `executeBatch` method, it wraps all the commands in a transaction and has less overhead.

```typescript
await QuickSQLite.transaction('myDatabase', (tx) => {
await NitroSQLite.transaction('myDatabase', (tx) => {
const { status } = tx.execute(
'UPDATE sometable SET somecolumn = ? where somekey = ?',
[0, 1]
Expand Down Expand Up @@ -117,7 +117,7 @@ const commands = [
[('INSERT INTO TEST (id) VALUES (?)', [[3], [4], [5], [6]])],
];

const res = QuickSQLite.executeSqlBatch('myDatabase', commands);
const res = NitroSQLite.executeSqlBatch('myDatabase', commands);

console.log(`Batch affected ${result.rowsAffected} rows`);
```
Expand All @@ -130,7 +130,7 @@ This can be done by testing the returned data directly, but in some cases may no
SQLite datatypes. When fetching data directly from tables or views linked to table columns, SQLite can identify the table declared types:

```typescript
let { metadata } = QuickSQLite.executeSql(
let { metadata } = NitroSQLite.executeSql(
'myDatabase',
'SELECT int_column_1, bol_column_2 FROM sometable'
);
Expand All @@ -148,7 +148,7 @@ metadata.forEach((column) => {
You might have too much SQL to process and it will cause your application to freeze. There are async versions for some of the operations. This will offload the SQLite processing to a different thread.

```ts
QuickSQLite.executeAsync(
NitroSQLite.executeAsync(
'myDatabase',
'SELECT * FROM "User";',
[]).then(({rows}) => {
Expand All @@ -170,15 +170,15 @@ SQLite has a limit for attached databases: A default of 10, and a global max of
References: [Attach](https://www.sqlite.org/lang_attach.html) - [Detach](https://www.sqlite.org/lang_detach.html)

```ts
QuickSQLite.attach('mainDatabase', 'statistics', 'stats', '../databases');
NitroSQLite.attach('mainDatabase', 'statistics', 'stats', '../databases');

const res = QuickSQLite.executeSql(
const res = NitroSQLite.executeSql(
'mainDatabase',
'SELECT * FROM some_table_from_mainschema a INNER JOIN stats.some_table b on a.id_column = b.id_column'
);

// You can detach databases at any moment
QuickSQLite.detach('mainDatabase', 'stats');
NitroSQLite.detach('mainDatabase', 'stats');
if (!detachResult.status) {
// Database de-attached
}
Expand All @@ -189,7 +189,7 @@ if (!detachResult.status) {
If you have a plain SQL file, you can load it directly, with low memory consumption.

```typescript
const { rowsAffected, commands } = QuickSQLite.loadFile(
const { rowsAffected, commands } = NitroSQLite.loadFile(
'myDatabase',
'/absolute/path/to/file.sql'
);
Expand All @@ -198,7 +198,7 @@ const { rowsAffected, commands } = QuickSQLite.loadFile(
Or use the async version which will load the file in another native thread

```typescript
QuickSQLite.loadFileAsync('myDatabase', '/absolute/path/to/file.sql').then(
NitroSQLite.loadFileAsync('myDatabase', '/absolute/path/to/file.sql').then(
(res) => {
const { rowsAffected, commands } = res;
}
Expand All @@ -210,7 +210,7 @@ QuickSQLite.loadFileAsync('myDatabase', '/absolute/path/to/file.sql').then(
On iOS you can use the embedded SQLite, when running `pod-install` add an environment flag:

```
QUICK_SQLITE_USE_PHONE_VERSION=1 npx pod-install
Nitro_SQLITE_USE_PHONE_VERSION=1 npx pod-install
```

On Android, it is not possible to link (using C++) the embedded SQLite. It is also a bad idea due to vendor changes, old android bugs, etc. Unfortunately, this means this library will add some megabytes to your app size.
Expand Down Expand Up @@ -240,7 +240,7 @@ bun patch-package --exclude 'nothing' typeorm

Now every time you install your node_modules that line will be added.

Next, we need to trick TypeORM to resolve the dependency of `react-native-sqlite-storage` to `react-native-quick-sqlite`, on your `babel.config.js` add the following:
Next, we need to trick TypeORM to resolve the dependency of `react-native-sqlite-storage` to `react-native-nitro-sqlite`, on your `babel.config.js` add the following:

```js
plugins: [
Expand All @@ -250,7 +250,7 @@ plugins: [
'module-resolver',
{
alias: {
"react-native-sqlite-storage": "react-native-quick-sqlite"
"react-native-sqlite-storage": "react-native-nitro-sqlite"
},
},
],
Expand All @@ -266,7 +266,7 @@ bun add babel-plugin-module-resolver
Finally, you will now be able to start the app without any metro/babel errors (you will also need to follow the instructions on how to setup TypeORM), now we can feed the driver into TypeORM:

```ts
import { typeORMDriver } from 'react-native-quick-sqlite'
import { typeORMDriver } from 'react-native-nitro-sqlite'

datasource = new DataSource({
type: 'react-native',
Expand All @@ -280,7 +280,7 @@ datasource = new DataSource({

# Loading existing DBs

The library creates/opens databases by appending the passed name plus, the [documents directory on iOS](https://github.com/margelo/react-native-quick-sqlite/blob/733e876d98896f5efc80f989ae38120f16533a66/ios/QuickSQLite.mm#L34-L35) and the [files directory on Android](https://github.com/margelo/react-native-quick-sqlite/blob/main/android/src/main/java/com/margelo/rnquicksqlite/QuickSQLiteBridge.java#L16), this differs from other SQL libraries (some place it in a `www` folder, some in androids `databases` folder, etc.).
The library creates/opens databases by appending the passed name plus, the [documents directory on iOS](https://github.com/margelo/react-native-nitro-sqlite/blob/733e876d98896f5efc80f989ae38120f16533a66/ios/NitroSQLite.mm#L34-L35) and the [files directory on Android](https://github.com/margelo/react-native-nitro-sqlite/blob/main/android/src/main/java/com/margelo/rnnitrosqlite/NitroSQLiteBridge.java#L16), this differs from other SQL libraries (some place it in a `www` folder, some in androids `databases` folder, etc.).

If you have an existing database file you want to load you can navigate from these directories using dot notation. e.g. `../www/myDb.sqlite`. Note that on iOS the file system is sand-boxed, so you cannot access files/directories outside your app bundle directories.

Expand All @@ -297,7 +297,7 @@ Add a `post_install` block to your `<PROJECT_ROOT>/ios/Podfile` like so:
```ruby
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "react-native-quick-sqlite" then
if target.name == "react-native-nitro-sqlite" then
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'SQLITE_ENABLE_FTS5=1'
end
Expand All @@ -314,7 +314,7 @@ For example, you could add `SQLITE_ENABLE_FTS5=1` to `GCC_PREPROCESSOR_DEFINITIO
You can specify flags via `<PROJECT_ROOT>/android/gradle.properties` like so:

```
quickSqliteFlags="<SQLITE_FLAGS>"
nitroSqliteFlags="<SQLITE_FLAGS>"
```

## Additional configuration
Expand All @@ -323,15 +323,15 @@ quickSqliteFlags="<SQLITE_FLAGS>"

On iOS, the SQLite database can be placed in an app group, in order to make it accessible from other apps in that app group. E.g. for sharing capabilities.

To use an app group, add the app group ID as the value for the `RNQuickSQLite_AppGroup` key in your project's `Info.plist` file. You'll also need to configure the app group in your project settings. (Xcode -> Project Settings -> Signing & Capabilities -> Add Capability -> App Groups)
To use an app group, add the app group ID as the value for the `RNNitroSQLite_AppGroup` key in your project's `Info.plist` file. You'll also need to configure the app group in your project settings. (Xcode -> Project Settings -> Signing & Capabilities -> Add Capability -> App Groups)

## Community Discord

[Join the Margelo Community Discord](https://discord.gg/6CSHz2qAvA) to chat about react-native-quick-sqlite or other Margelo libraries.
[Join the Margelo Community Discord](https://discord.gg/6CSHz2qAvA) to chat about react-native-nitro-sqlite or other Margelo libraries.

## Oscar

react-native-quick-sqlite was originally created by [Oscar Franco](https://github.com/ospfranco). Thanks Oscar!
react-native-nitro-sqlite was originally created by [Oscar Franco](https://github.com/ospfranco). Thanks Oscar!

## License

Expand Down
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ android {
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion

namespace "com.margelo.rnquicksqlite.example"
namespace "com.margelo.rnnitrosqlite.example"
defaultConfig {
applicationId "com.margelo.rnquicksqlite.example"
applicationId "com.margelo.rnnitrosqlite.example"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.margelo.rnquicksqlite.example
package com.margelo.rnnitrosqlite.example

import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
Expand All @@ -11,7 +11,7 @@ class MainActivity : ReactActivity() {
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
override fun getMainComponentName(): String = "QuickSQLiteExample"
override fun getMainComponentName(): String = "NitroSQLiteExample"

/**
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.margelo.rnquicksqlite.example;
package com.margelo.rnnitrosqlite.example;

import android.app.Application
import com.facebook.react.PackageList
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<resources>
<string name="app_name">QuickSQLiteExample</string>
<string name="app_name">NitroSQLiteExample</string>
</resources>
2 changes: 1 addition & 1 deletion example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pluginManagement { includeBuild("../../node_modules/@react-native/gradle-plugin") }
plugins { id("com.facebook.react.settings") }
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
rootProject.name = 'QuickSQLiteExample'
rootProject.name = 'NitroSQLiteExample'
include ':app'
includeBuild('../../node_modules/@react-native/gradle-plugin')
12 changes: 6 additions & 6 deletions example/app.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "QuickSQLiteExample",
"displayName": "QuickSQLite Example",
"name": "NitroSQLiteExample",
"displayName": "NitroSQLite Example",
"components": [
{
"appKey": "QuickSQLiteExample",
"displayName": "QuickSQLite Example"
"appKey": "NitroSQLiteExample",
"displayName": "NitroSQLite Example"
}
],
"resources": {
Expand All @@ -15,9 +15,9 @@
"windows": ["dist/assets", "dist/main.windows.bundle"]
},
"android": {
"package": "com.margelo.rnquicksqlite.example"
"package": "com.margelo.rnnitrosqlite.example"
},
"ios": {
"bundleIdentifier": "com.margelo.rnquicksqlite.example"
"bundleIdentifier": "com.margelo.rnnitrosqlite.example"
}
}
2 changes: 1 addition & 1 deletion example/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
alias: {
[pak.name]: path.join(__dirname, '../package', pak.source),
stream: 'stream-browserify',
'react-native-sqlite-storage': 'react-native-quick-sqlite',
'react-native-sqlite-storage': 'react-native-nitro-sqlite',
},
},
],
Expand Down
Loading

0 comments on commit 66069ab

Please sign in to comment.