You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Big rewrite to prepare for future changes. This now uses Typescript and Webpack to build everything.
Some breaking changes to eliminate extend usage.
Supersedes #116 and thus should also solve #86
This package contains its own type definitions. Due to the nature of setSchema, which alters the database on which it is called, typescript needs to know about these changes. This is done by returning a new type. So working with this plugin should look something like this:
61
+
62
+
```js
63
+
importPouchfrom'pouchdb-core';
64
+
//import some adapter
65
+
importfindfrom'pouchdb-find';
66
+
importrelfrom'relational-pouch';
67
+
68
+
Pouch
69
+
//.plugin(someadapter)
70
+
.plugin(find)
71
+
.plugin(rel);
72
+
73
+
constbaseDB=newPouch(...);//adapter options
74
+
constrelDB=baseDB.setSchema(...);//schema options
75
+
76
+
let relDoc =awaitrelDB.rel.find('sometype', 'someid');
77
+
78
+
//non relation pouch API is still available
79
+
let doc =awaitrelDB.get('someid');
80
+
```
81
+
82
+
58
83
API
59
84
----------
60
85
@@ -167,14 +192,8 @@ Result:
167
192
168
193
```js
169
194
{
170
-
"posts": [
171
-
{
172
-
"title":"Rails is Omakase",
173
-
"text":"There are a lot of a-la-carte software...",
174
-
"id":"14760983-285C-6D1F-9813-D82E08F1AC29",
175
-
"rev":"1-84df2c73028e5b8d0ae1cbb401959370"
176
-
}
177
-
]
195
+
"id":"14760983-285C-6D1F-9813-D82E08F1AC29",
196
+
"rev":"1-84df2c73028e5b8d0ae1cbb401959370"
178
197
}
179
198
```
180
199
@@ -192,14 +211,8 @@ Result:
192
211
193
212
```js
194
213
{
195
-
"posts": [
196
-
{
197
-
"title":"Rails is Unagi",
198
-
"text":"Delicious unagi. Mmmmmm.",
199
-
"id":1,
200
-
"rev":"1-0ae315ee597b22cc4b1acf9e0edc35ba"
201
-
}
202
-
]
214
+
"id":1,
215
+
"rev":"1-0ae315ee597b22cc4b1acf9e0edc35ba"
203
216
}
204
217
```
205
218
@@ -359,25 +372,10 @@ var attachment = new Blob(['Is there life on Mars?']);
This will run the tests in Node using memory and http adapter:
1122
1113
1123
1114
npm test
1124
1115
1116
+
if you don't have a admin party setup you can specify admin credentials in the RELATIONAL_POUCH_DB_AUTH environment variable like this:
1117
+
1118
+
RELATIONAL_POUCH_DB_AUTH=user:password@
1119
+
1125
1120
You can also check for 100% code coverage using:
1126
1121
1127
1122
npm run coverage
@@ -1150,3 +1145,20 @@ You can run e.g.
1150
1145
CLIENT=selenium:phantomjs npm test
1151
1146
1152
1147
This will run the tests automatically and the process will exit with a 0 or a 1 when it's done. Firefox uses IndexedDB, and PhantomJS uses WebSQL.
1148
+
1149
+
## Changelog
1150
+
1151
+
### 4.0.0
1152
+
1153
+
- Breaking change: To prevent us from having to do cloning of input documents, we have changed the `save`, `putAttachment` and `removeAttachment` API. These functions no longer return the complete document. The attachment functions only return the new `rev` value, while the save will also return the `id`. So after these promises resolve you have to manually update your in app data to reflect this new revision (and possibly id) if you want to update the document later. You can use something like the following:
1154
+
```js
1155
+
let updatedData =awaitdb.rel.save('post', post);
1156
+
Object.assign(post, updatedData);
1157
+
```
1158
+
or
1159
+
```js
1160
+
post.rev=awaitdb.rel.putAttachment('post', post, 'file', fileData);
1161
+
```
1162
+
- This library now uses Typescript, Webpack and Babel in its build setup. The build creates files in 2 output directories: lib and dist.
1163
+
- The lib directory will contain the output of `tsc` in esnext mode. So this can be used by Webpack and other module aware systems. These will require Babel transformations if you want to use them, but this way you can specify your own target.
1164
+
- The dist directory contains 2 files, pouchdb.relational-pouch.browser.js and pouchdb.relational-pouch.node.js. These are compiled by webpack with targets ">2%, not ie 11" and "node 10". This should be sufficient for now, but otherwise you can build your own with Webpack.
0 commit comments