First Tİme CouchDB-Status:200 but no data displayed[SOLVED]

Hi everyone, I am trying to use CouchDB for an app.I have installed it succesfully and generated an app.Installed add-ons “ember-pouch” and “add-cors-to-couchdb”.Configured the way “ember-pouch” document suggests.I have manually generated a document but it is not displaying.

You can see request made and console log it gives on pictures.Also when i hit save button, it doesn’t make any xhr request.I am alerting title to see if it is working, and it succesfully alerts title.

Here is the adapter;

import PouchDB from 'pouchdb';
import { Adapter } from 'ember-pouch';

 PouchDB.debug.enable('*');

var remote = new PouchDB('http://127.0.0.1:5984/offline');
var db = new PouchDB('local_pouch');

db.sync(remote, {
   live: true,   // do a live, ongoing sync
   retry: true   // retry if the conection is lost
});

export default Adapter.extend({
  db: db
});

As i said, this is my first time using couchDB.So if i have missed small detail, please reveal it to me and TIA.

Code looks good. The title is not written by ember-pouch because it is not in a data field.

I guess the mistake is, couchdb doesn’t know which document belongs to which object model. Check this source below.Data is displayed without a type.So it can’t say which model it belongs to.I manually add the type field but it didn’t solve it.BTW, i couldn’t generate data the way you show here.How can i add both “key” and “value” to a value field ?

Just run something like this and see how the record is created:

https://github.com/broerse/ember-cli-blog/blob/master/app/routes/posts.js#L17

1 Like

I got it working.All i did was taking “createInspection” action out of the routes file and put it in a controller.

May i ask, do we have to do it in controller? I see you have done it in the routes file but used setupController hook.Would it be a bad practice if i just use controller?

Nice you got it working. The setupController hook has nothing to do with the actions here. It is some leftover code. Still need to cleanup :wink:

Anticipating the future switch to routable components I think it is better to do this actions on the router. I am sure it will not be much work to do this later and keep the actions on the controller.

1 Like

For my own sanity, i think i will use controller for a while, because it doesn’t respond to my route actions :slight_smile:

Do you know what was interesting, when i use actions in route, XHR says 201 created but no record is actually there.Have you ever came across to this?

No. Should not be the case…