Skip to content

Commit 7b81e3c

Browse files
committed
chore(*): Copied commits from the private repo:
* `467b794` 2 weeks ago [Takuya Matsuyama] 4.0.4 (HEAD -> main, tag: v4.0.4, origin/main) * `bded991` 2 weeks ago [Takuya Matsuyama] fix(example): add bulk docs test * `6df0da5` 2 weeks ago [Takuya Matsuyama] fix(bulk-docs): rewrite with async/await * `1139876` 2 weeks ago [Takuya Matsuyama] fix(core): add _remote prop * `a4b2164` 5 weeks ago [Takuya Matsuyama] 4.0.3 (tag: v4.0.3) * `cdb37fa` 5 weeks ago [Takuya Matsuyama] fix(utils): compaction not working * `ff228f4` 5 weeks ago [Takuya Matsuyama] 4.0.2 (tag: v4.0.2) * `c764b5f` 5 weeks ago [Takuya Matsuyama] fix(core): type() is deprecated * `bca1f33` 5 weeks ago [Takuya Matsuyama] fix(package): op-sqlite should be in dependencies * `acac93d` 5 weeks ago [Takuya Matsuyama] 4.0.1 (tag: v4.0.1) * `da9c932` 5 weeks ago [Takuya Matsuyama] feat(example): add buttons for testing local docs * `4df77fc` 5 weeks ago [Takuya Matsuyama] chore: lock * `1800212` 5 weeks ago [Takuya Matsuyama] chore(dep): bump up op-sqlite * `fc896d3` 5 weeks ago [Takuya Matsuyama] fix(core): removeLocal never call callback * `5cb0a12` 5 weeks ago [Takuya Matsuyama] fix(core): cannot check encoding
1 parent 2e6a0f2 commit 7b81e3c

File tree

12 files changed

+492
-517
lines changed

12 files changed

+492
-517
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
9+
indent_style = space
10+
indent_size = 2
11+
12+
end_of_line = lf
13+
charset = utf-8
14+
trim_trailing_whitespace = true
15+
insert_final_newline = true

.gitignore

100755100644
File mode changed.

LICENSE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 Takuya Matsuyama
4-
3+
Copyright (c) 2024 Takuya Matsuyama
54
Permission is hereby granted, free of charge, to any person obtaining a copy
65
of this software and associated documentation files (the "Software"), to deal
76
in the Software without restriction, including without limitation the rights

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ PODS:
4242
- hermes-engine (0.74.2):
4343
- hermes-engine/Pre-built (= 0.74.2)
4444
- hermes-engine/Pre-built (0.74.2)
45-
- op-sqlite (6.0.6):
45+
- op-sqlite (6.2.11):
4646
- DoubleConversion
4747
- glog
4848
- hermes-engine
@@ -1464,7 +1464,7 @@ SPEC CHECKSUMS:
14641464
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
14651465
glog: fdfdfe5479092de0c4bdbebedd9056951f092c4f
14661466
hermes-engine: 01d3e052018c2a13937aca1860fbedbccd4a41b7
1467-
op-sqlite: b7852adda5c225bd53c8a0b451992b713c89ae64
1467+
op-sqlite: 0f2a39082e75386cc601749841f19b9eeaf3c6e0
14681468
OpenSSL-Universal: 6e1ae0555546e604dbc632a2b9a24a9c46c41ef6
14691469
RCT-Folly: 02617c592a293bd6d418e0a88ff4ee1f88329b47
14701470
RCTDeprecation: b03c35057846b685b3ccadc9bfe43e349989cdb2
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

example/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"dependencies": {
1212
"@craftzdog/react-native-buffer": "^6.0.5",
13-
"@op-engineering/op-sqlite": "^6.0.6",
13+
"@op-engineering/op-sqlite": "^6.2.11",
1414
"debug": "^4.3.5",
1515
"expo": "~51.0.14",
1616
"expo-build-properties": "~0.12.3",
@@ -31,8 +31,6 @@
3131
"babel-plugin-module-resolver": "^5.0.2"
3232
},
3333
"op-sqlite": {
34-
"performanceMode": "2",
35-
"iosSqlite": false,
3634
"fts5": true
3735
},
3836
"private": true

example/src/App.tsx

Lines changed: 89 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
ScrollView,
1111
} from 'react-native'
1212
import PouchDB from './pouchdb'
13-
import { open } from '@op-engineering/op-sqlite'
13+
// import { open } from '@op-engineering/op-sqlite'
1414

1515
// @ts-ignore eslint-ignore-next-line
1616
const uiManager = global?.nativeFabricUIManager ? 'Fabric' : 'Paper'
@@ -21,26 +21,26 @@ const pouch = new PouchDB('mydb', {
2121
adapter: 'react-native-sqlite',
2222
})
2323

24-
async function run() {
25-
const db = open({ name: 'test' })
26-
db.execute(
27-
'CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, name TEXT)'
28-
)
29-
30-
await db.transaction(async (tx) => {
31-
await Promise.all(
32-
Array.from({ length: 100 }, (_, i) =>
33-
tx
34-
.executeAsync('INSERT INTO test (name) VALUES (?)', ['foo'])
35-
.then((result) => console.log('insertId:', result.insertId))
36-
)
37-
)
38-
})
39-
40-
db.execute('DROP TABLE IF EXISTS test')
41-
}
42-
43-
run()
24+
// async function run() {
25+
// const db = open({ name: 'test' })
26+
// db.execute(
27+
// 'CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, name TEXT)'
28+
// )
29+
//
30+
// await db.transaction(async (tx) => {
31+
// await Promise.all(
32+
// Array.from({ length: 100 }, (_, i) =>
33+
// tx
34+
// .executeAsync('INSERT INTO test (name) VALUES (?)', ['foo'])
35+
// .then((result) => console.log('insertId:', result.insertId))
36+
// )
37+
// )
38+
// })
39+
//
40+
// db.execute('DROP TABLE IF EXISTS test')
41+
// }
42+
//
43+
// run()
4444

4545
export default function App() {
4646
const [result, setResult] = React.useState<string>('')
@@ -81,6 +81,39 @@ export default function App() {
8181
console.log('put:', r)
8282
setResult(JSON.stringify(r, null, 2))
8383
}
84+
const handlePutMultiDocs = async () => {
85+
setResult('')
86+
let count = 0
87+
88+
try {
89+
const res = await pouch.bulkDocs(
90+
Array.from({ length: 10 }, (_, i) => ({
91+
_id: `test:${i}`,
92+
title: 'Heroes',
93+
count: count + 1,
94+
}))
95+
)
96+
setResult(JSON.stringify(res, null, 2))
97+
} catch (e: any) {
98+
setResult(e.name + ': ' + e.message + '\n' + e.stack)
99+
console.error(e)
100+
}
101+
}
102+
// const handlePutMultiDocs = async () => {
103+
// setResult('')
104+
// let count = 0
105+
//
106+
// const res = await Promise.all(
107+
// Array.from({ length: 100 }, (_, i) =>
108+
// pouch.put({
109+
// _id: `test:${i}`,
110+
// title: 'Heroes',
111+
// count: count + 1,
112+
// })
113+
// )
114+
// )
115+
// setResult(JSON.stringify(res, null, 2))
116+
// }
84117
const handleRemoveDoc = async () => {
85118
setResult('')
86119
try {
@@ -147,6 +180,32 @@ export default function App() {
147180
}
148181
}
149182

183+
const handleWriteLocalDoc = async () => {
184+
setResult('')
185+
try {
186+
const result = await pouch.put({
187+
_id: '_local/mydoc',
188+
title: 'Heroes',
189+
})
190+
console.log('ret:', result)
191+
setResult(JSON.stringify(result, null, 2))
192+
} catch (e: any) {
193+
setResult(e.name + ': ' + e.message)
194+
}
195+
}
196+
197+
const handleRemoveLocalDoc = async () => {
198+
setResult('')
199+
try {
200+
const mydoc = await pouch.get('_local/mydoc')
201+
const result = await pouch.remove(mydoc)
202+
console.log('ret:', result)
203+
setResult(JSON.stringify(result, null, 2))
204+
} catch (e: any) {
205+
setResult(e.name + ': ' + e.message)
206+
}
207+
}
208+
150209
return (
151210
<ScrollView
152211
style={styles.container}
@@ -161,6 +220,9 @@ export default function App() {
161220
<TouchableOpacity onPress={handlePutDoc} style={styles.button}>
162221
<Text style={styles.buttonText}>Put a doc</Text>
163222
</TouchableOpacity>
223+
<TouchableOpacity onPress={handlePutMultiDocs} style={styles.button}>
224+
<Text style={styles.buttonText}>Put docs</Text>
225+
</TouchableOpacity>
164226
<TouchableOpacity onPress={handleRemoveDoc} style={styles.button}>
165227
<Text style={styles.buttonText}>Delete a doc</Text>
166228
</TouchableOpacity>
@@ -176,6 +238,12 @@ export default function App() {
176238
<TouchableOpacity onPress={handleGetAttachment} style={styles.button}>
177239
<Text style={styles.buttonText}>Get an attachment</Text>
178240
</TouchableOpacity>
241+
<TouchableOpacity onPress={handleWriteLocalDoc} style={styles.button}>
242+
<Text style={styles.buttonText}>Write a local doc</Text>
243+
</TouchableOpacity>
244+
<TouchableOpacity onPress={handleRemoveLocalDoc} style={styles.button}>
245+
<Text style={styles.buttonText}>Remove a local doc</Text>
246+
</TouchableOpacity>
179247
{imageData && (
180248
<Image
181249
source={{ uri: imageData }}

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pouchdb-adapter-react-native-sqlite",
3-
"version": "4.0.0-rc.3",
3+
"version": "4.0.4",
44
"description": "PouchDB adapter for React Native SQLite",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",
@@ -78,7 +78,7 @@
7878
"@types/react": "^18.2.44"
7979
},
8080
"dependencies": {
81-
"@op-engineering/op-sqlite": "^6.0.7",
81+
"@op-engineering/op-sqlite": "^6.2.11",
8282
"debug": "^4.3.5",
8383
"pouchdb-adapter-utils": "^8.0.1",
8484
"pouchdb-binary-utils": "^8.0.1",
@@ -88,7 +88,6 @@
8888
"pouchdb-utils": "^8.0.1"
8989
},
9090
"peerDependencies": {
91-
"@op-engineering/op-sqlite": "^6.0.7",
9291
"react": "*",
9392
"react-native": "*"
9493
},

0 commit comments

Comments
 (0)