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
Copy file name to clipboardExpand all lines: README.md
+28-5Lines changed: 28 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
# Ember Pouch [](https://travis-ci.org/pouchdb-community/ember-pouch)[](https://badge.fury.io/gh/pouchdb-community%2Fember-pouch)[](https://emberobserver.com/addons/ember-pouch)
2
2
3
-
[**Changelog**](#changelog)
3
+
-[**Changelog**](#changelog)
4
+
-[**Upgrading**](#upgrading)
4
5
5
6
Ember Pouch is a PouchDB/CouchDB adapter for Ember Data 3.16+. For older Ember Data versions down to 2.0+ use Ember Pouch version 7.0 For Ember Data versions lower than 2.0+ use Ember Pouch version 3.2.2.
-`import {Model, Adapter, Serializer} from 'ember-pouch'`
41
41
42
42
`Ember-Pouch` requires you to add a `@attr('string') rev` field to all your models. This is for PouchDB/CouchDB to handle revisions:
@@ -67,6 +67,9 @@ export default class TodoModel extends Model {
67
67
}
68
68
```
69
69
70
+
The installation creates a file `adapters/application.js` that you can use by default to setup the database connection. Look at the [Adapter blueprint](#adapter) section to see the settings that you have to set in your config file to work with this adapter.
71
+
It also installs the required packages.
72
+
70
73
## Configuring /app/adapters/application.js
71
74
72
75
A local PouchDB that syncs with a remote CouchDB looks like this:
@@ -119,10 +122,10 @@ Replace `<model-name>` with the name of your model and the file will automatical
119
122
120
123
### Adapter
121
124
122
-
You can now create an adapter using ember-cli's blueprint functionality. Once you've installed `ember-pouch` into your ember-cli app you can run the following command to automatically generate an application adapter.
125
+
You can now create an adapter using ember-cli's blueprint functionality. Once you've installed `ember-pouch` into your ember-cli app you can run the following command to automatically generate an adapter.
123
126
124
127
```
125
-
ember g pouch-adapter application
128
+
ember g pouch-adapter foo
126
129
```
127
130
128
131
Now you can store your localDb and remoteDb names in your ember-cli's config. Just add the following keys to the `ENV` object:
This blueprint is run on installation for the `application` adapter.
139
+
140
+
You can use multiple adapters, but be warned that doing the `.plugin` calls in multiple adapter files will result in errors: `TypeError: Cannot redefine property: replicate`. In this case it is better to move the `PouchDB.plugin` calls to a separate file.
141
+
135
142
## Relationships
136
143
137
144
EmberPouch supports both `hasMany` and `belongsTo` relationships.
@@ -544,6 +551,18 @@ Following the CouchDB consistency model, we have introduced `ENV.emberPouch.even
544
551
`findRecord` now returns a long running Promise if the record is not found. It only rejects the promise if a deletion of the record is found. Otherwise this promise will wait for eternity to resolve.
545
552
This makes sure that belongsTo relations that have been loaded in an unexpected order will still resolve correctly. This makes sure that ember-data does not set the belongsTo to null if the Pouch replicate would have loaded the related object later on. (This only works for async belongsTo, sync versions will need this to be implemented in relational-pouch)
546
553
554
+
## Upgrading
555
+
556
+
### Version 8
557
+
558
+
Version 8 introduces the custom PouchDB setup in the adapter instead of having a default setup in `addon/pouchdb.js`. So if you used `import PouchDB from 'ember-pouch/pouchdb'` in your files, you now have to make your own 'PouchDB bundle' in the same way we do it in the default adapter blueprint. The simplest way to do this is to run the blueprint by doing `ember g ember-pouch` (which will overwrite your application adapter, so make sure to commit that file first) and take the `import PouchDB from...` until the final `.plugin(...)` line and put that into your original adapter (or a separate file if you use more than one adapter).
559
+
You can also copy the lines from [the blueprint file in git](https://github.com/pouchdb-community/ember-pouch/blob/master/blueprints/pouch-adapter/files/__root__/adapters/__name__.js)
560
+
561
+
We also removed the pouchdb-browser package and relational-pouch as a package.json dependency, so you will have to install the packages since the lines above depend upon.
This way you can now decide for yourself which PouchDB plugins you want to use. You can even remove the http or indexeddb ones if you just want to work offline or online.
565
+
547
566
## Installation
548
567
549
568
-`git clone` this repository
@@ -572,7 +591,11 @@ This project was originally based on the [ember-data-hal-adapter](https://github
572
591
And of course thanks to all our wonderful contributors, [here](https://github.com/pouchdb-community/ember-pouch/graphs/contributors) and [in Relational Pouch](https://github.com/pouchdb-community/relational-pouch/graphs/contributors)!
573
592
574
593
## Changelog
575
-
594
+
-**8.0.0-beta.2**
595
+
- Set PouchDb indexeddb adapter as default instead of idb adapter to use native views
596
+
- Generate adapters/application.js at installation
597
+
- move package.json dependencies to default blueprint
598
+
- removed Adapter `fixDeleteBug` flag. We now do a client side `destroyRecord` with custom `adapterOptions` to signal to the ember-data store that the record is deleted. So no more hacking ember-data is needed in the addon to support the server pushed deletes.
576
599
-**8.0.0-beta.1**
577
600
- Updated to support latest Ember 4.x (fixed isDeleted issues)
578
601
- Switch to PouchDB 7.3.0. Getting ready to use the indexeddb-adapter
0 commit comments