Skip to content

Commit 2145271

Browse files
committed
chore: remove README section
1 parent cab8330 commit 2145271

File tree

1 file changed

+0
-56
lines changed

1 file changed

+0
-56
lines changed

README.md

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -148,62 +148,6 @@ const res = NitroSQLite.executeSqlBatch('myDatabase', commands);
148148
console.log(`Batch affected ${result.rowsAffected} rows`);
149149
```
150150

151-
## Sending and receiving nullish values
152-
153-
Due to internal limitations with Nitro modules, we have to handle nullish values explicitly in NitroSQLite. There are two ways to send and receive null values:
154-
155-
### Default null handling
156-
157-
By default, the user can pass the `NITRO_SQLITE_NULL` constant instead of `null` or `undefined` to query params and will also receive this constant for nullish values in e.g. `SELECT` queries. `NITRO_SQLITE_NULL` is the object that is used internally to handle nullish values, therefore **this approach does NOT introduce any performance overhead**.
158-
159-
A `INSERT` query with nullish values could look like this:
160-
161-
```typescript
162-
import { NITRO_SQLITE_NULL } from 'react-native-nitro-sqlite'
163-
164-
db.execute(
165-
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
166-
[1, "Mike", NITRO_SQLITE_NULL, NITRO_SQLITE_NULL]
167-
)
168-
```
169-
170-
Query results that are received from e.g. `execute()` will also return this special object/struct. To check for null values, the user can use the a special function:
171-
172-
```typescript
173-
import { isNitroSQLiteNull } from 'react-native-nitro-sqlite'
174-
175-
const res = db.execute('SELECT * FROM User')
176-
177-
const firstItem = res.rows?.item(0)
178-
if (isNitroSQLiteNull(firstItem.age) {
179-
// Handle null value
180-
}
181-
```
182-
183-
### Simplified null handling
184-
185-
To enable simple null handling, call `enableSimpleNullHandling()` in the root of your project. This will allow you to just pass `null` or `undefined` to NitroSQLite functions, e.g. as query params. in `execute()`:
186-
187-
```typescript
188-
db.execute(
189-
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
190-
[1, "Mike", null, undefined]
191-
)
192-
```
193-
194-
Note that in SQLite, both `undefined` and `null` are transformed into the same representation in the database. Therefore, nullish values received from `SELECT` queries will always evaluate to `null`, even if `undefined` was used in the `INSERT` query.
195-
196-
```typescript
197-
const res = db.execute('SELECT * FROM User')
198-
199-
const firstItem = res.rows?.item(0)
200-
if (firstItem.age === null) { // Nullish values will always be null and never undefined.
201-
// Handle null value
202-
}
203-
```
204-
205-
Simple null handling adds some logic to internally transform nullish values into a special object/struct and vice versa, that is sent/received from the native C++ side. This **might introduce some performance overhead**, since we have to loop over the params and query results and check for this structure.
206-
207151
## Dynamic Column Metadata
208152

209153
In some scenarios, dynamic applications may need to get some metadata information about the returned result set.

0 commit comments

Comments
 (0)