pouchdb-community / ember-pouch

PouchDB/CouchDB adapter for Ember Data
Apache License 2.0
281 stars 76 forks source link

Move 'pouchdb' to its own ember-cli addon #120

Open fivetanley opened 8 years ago

fivetanley commented 8 years ago

Sometimes, I need to do something that doesn't use Ember Data or implement my own Ember Data adapter due to reasons™.

Here's some stuff I've been working on that the separation would help:

1) Fastboot, it's easier to manage the pouch source when it is its own plugin rather than continuing to add shim files. I'm working on an addon that does this work for you. 2) A JSONAPI-ish adpater for PouchDB (writes jsonapidocs instead of ember-relational). 3) It would be nice to be able to load pouchdb-relational separately via an import statement instead of having it always included if possible.

This wouldn't be a breaking change, as ember-pouch (this addon) could rely on the new addon . Alternatively, the ember data stuff in this addon could be moved to a new addon instead. This would be a breaking change.

As always, thanks for everything. Pouch is a great ecosystem.

I'd be happy to help with anything to facilitate this.

broerse commented 8 years ago

Ember is moving away from bower. I don't think pouchdb needs to be an ember-cli addon but it would be logical for ember-pouch to move to the NPM versions of pouchdb and relational-pouch

https://github.com/nolanlawson/ember-pouch/blob/master/index.js#L31

Perhaps you can start there?

backspace commented 8 years ago

@broerse, @fivetanley is the person who migrated Ember Data into an addon, allowing us all to remove it from bower.json :grinning:

Your ideas sound good to me. I’m particularly interested in the JSON API-like adapter idea. Making it configurable would be great so people could keep using relational-pouch if they want but also able to opt in to the JSON API adapter, if it has advantages for them. What are you thinking would be advantages to such an adapter?

Since you’re intimately acquainted with Ember Data, do you have any idea whether it’s possible to automate the saving of parent records in a hasMany relationship? So we don’t need things like this.

broerse commented 8 years ago

Did not know :smile:. Perhaps I also misunderstand. What does the pouchdb ember-cli addon have what the pouchdb NPM version does not have?

fivetanley commented 8 years ago

It's just the that npm version is currently more work to get in right now. :p It works marvelously in Fastboot though.

broerse commented 8 years ago

@fivetanley If you help me I am willing to putt in the energy to move to the npm versions.

broerse commented 8 years ago

@fivetanley What work needs to be done to make https://www.npmjs.com/package/pouchdb work with ember-pouch ??

nolanlawson commented 8 years ago

FWIW, we now have custom builds, so you could make a custom build that e.g. uses in-memory storage in Node and regular IDB+WebSQL in the browser. Dunno if that's helpful for the FastBoot stuff or not, but I imagine the leveldown dependency in the npm package will slow down npm installs if nothing else.

Sample:

// package.json
{
  "browser": {
    "index.js": "browser.js"
  }
}
// index.js
module.exports = require('pouchdb-core')
  .plugin(require('pouchdb-mapreduce'))
  .plugin(require('pouchdb-replication'))
  .plugin(require('pouchdb-adapter-memory'))
// browser.js
module.exports = require('pouchdb-core')
  .plugin(require('pouchdb-mapreduce'))
  .plugin(require('pouchdb-replication'))
  .plugin(require('pouchdb-adapter-idb'))
  .plugin(require('pouchdb-adapter-websql'))
broerse commented 7 years ago

Switched to npm only: https://github.com/nolanlawson/ember-pouch/releases/tag/v4.2.0

gr2m commented 7 years ago

I have some experiences with PouchDD, the custom builds, and making it run on both browsers and Node, as we have the same use cases at Hoodie. Also from own experience I can tell that getting rid of the levelDB dependency so absolutely glorious :)

I’ve little experiences (but lots of interest now) with Ember / Ember Data. If you point me to the right places, I’m happy to help out.

I’d particularly be interested to make relational-pouch optional for apps that don’t use relations

broerse commented 7 years ago

@gr2m Thanks! We would like some help. I have no experience with Fastboot so help to get it compatible would be a good start, I think that we must also let future tree-shaking like with rollup decide if we use relational-pouch. The Ember team has not decided on what tree-shaking they will use but we have to prepare.

jacobq commented 4 years ago

I think this issue can be closed due to age / inactivity, no? Thanks to ember-auto-import it should be much easier to get node modules like pouchdb into Ember apps now.

jlami commented 4 years ago

I agree that this is an old topic. But I'm working on removing leveldown from the npm install and this might be a good place to continue the discussion on whether we want relational-pouch as a dependency. And how (or even if) we want the app to configure which pouch bundle/setup he wants to use.

For now I think we should keep it simple for new users, so a one line import in app/adapter might be best. Advanced users can then just replace that line with their own requirements.

import PouchDB from 'ember-pouch/pouchdb';

We could generate that addon file in index.js based on config settings, but that might be overkill if we want to start with just eliminating leveldown.