Ember-pouch and pouch-find to work on data already in couchDB server?



I am new to Ember; have got stuck trying to understand the data store behaviour. Other people seemed to have had similar difficulties but I cannot find anything that actually fits my current setup.

using ember-pouch as described in their guide

in my route code, this.get(‘store’).findRecord(‘video’, “id1234”); works fine, it returns the object in the database with id1234.

however, return this.get(‘store’).findAll(‘video’); only returns items which have already been specifically queried by id first. The server couchdb that is being synched to contains about 1000 items, I would like to have these returned by the findAll query.

Similar issue with pouchdb-find:

  • the typical queries return empty answers (no records found)
  • however in the adapter code, I can get a perfect response (all matching query records) by asking pouchdb-find directly, once an index has been setup, for example with: db.find({selector: { type: ‘myTargetVideoType’}}); this line works great first time. The data store does not.

So… It looks as though the “db” element does everything I want it to do very easily, send back all the records, give back everything I query for, but the this.get(‘store’) just keeps on sending back empty records and ignoring what is already in the database.

Sounds like there is a simple solution to this, but what is it?

Thanks in advance if anyone can give guidance!



I think @broerse usually has the most helpful answers with Pouch/Couch. Maybe he can weigh in…


I don’r recognize this behavior. Perhaps test https://github.com/broerse/ember-cli-blog and if that works try to find the difference.


Thank you for your suggestion, I have started to look and it already shows some different code in init() for the adapter that seems to implement synching to the remote database. This may be what was missing, I will confirm when checked.


Hi there,

I have done a simple test and the problem (unless I am missing something) seems to be reproducible on https://github.com/broerse/ember-cli-blog

To reproduce

  • ember serve to start a blank blog server that has been configured to point towards a couchdb server on another machine

  • create a trivial post

  • check on the couch server the post appears, in my case I could see the following entry (created by the website) { “_id”: “post_2_47CA3B46-7085-C660-AA23-8EC9FF9098C7”, “_rev”: “2-dc55008b23e84dd5828ff2f781dbf5d3”, “data”: { “title”: “Hello toto”, “date”: “2018-06-15T19:11:37.192Z”, “excerpt”: “This is toto”, “body”: “Toto’s post comes here”, “author”: null } }

  • now go into futon on the couchdb server and create a server side copy paste of the post: { “_id”: “07ab038a6a2be68b46d79cd1dc013217”, “_rev”: “1-4770baf130e9f729cdc4154117d2959a”, “data”: { “title”: “Hello toto from couch”, “date”: “2018-06-15T19:13:37.192Z”, “excerpt”: “This is toto from couch”, “body”: “Toto’s post from couch comes here”, “author”: null } }

  • return to the localhost:4200 server (if you want restart ember serve, etc): there is only one post, the one that was created locally, in the list of posts. The additional one created on the server side appears to be ignored.

Am I missing something?




You are missing that the _id contains the model and the ember-data ID. So your ID should be post_2_07ab038a6a2be68b46d79cd1dc013217. You always have to add _2_ after the model. See for more info https://github.com/pouchdb-community/relational-pouch#how-does-it-work


Ah - thank you @broerse ! :bulb::bulb: :pray:

So, if you wanted to in ember to present and manipulate data that is already sitting in a couchdb server, and that does not have this kind of structure in the ids, what would the best approach be - can you talk with couch out of the box directly with the JSON or REST adapter, or is it down to writing your own, or is there a recommended package?


CouchDB is all about sync and the normal JSON and REST adapters are not. Perhaps you need to write your own but if the model is not in the ID how does your CouchDB handle different models at the moment? Perhaps it is easier to do a one time convert to change the ID’s on the existing database.


thank you - makes sense, it is really helpful to understand the lay of the land.