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.
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 ?
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
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.