Extend Ember RESTAdapter to work with CouchDB - ember.js

I am using CouchDB for basically my entire back-end, and Ember for basically my entire front-end, and I need to find a way to make the json data compatible between the two, especially regarding the 'named root' convention (here are the ember json expectations and the couch api). I'm not using Ruby or any other libraries, so I'm quite sure this couch adapter isn't available to me.
I read here that I'll need to extend the extract method to get this to work properly, but I'm freaked out by this whole thing and am not sure where to start. What's the relationship between RESTAdapter and JSONSerializer? I'm not sure how this all fits together and I'm terrified of wasting time and possibly screwing something up. And is there maybe an easier way to do this?
Forgive my noobiness.

There's a CouchDB adapter that does seem to be up to date (last updated 2 days ago), at https://github.com/roundscope/ember-couchdb-kit. As it says, "Inspired by pangratz/ember-couchdb-adapter and contains many fixes and newbie features."
While the installation is easy within a Rails project, it's still fine outside of a Rails project. Just include everything from the dist directory in this order:
ember-couchdb-kit
registry
document-adapter
attachment-adapter
revs-adapter
changes-feed

I read here that I'll need to extend the extract method to get this to work properly
The SO post (and the couch adapter) you referenced are out-of-date. Ember Data changed a lot in the past few weeks, so lots of the old answers out there could be misleading.
I'm freaked out by this whole thing and am not sure where to start.
The good news is it's become somewhat easier to do the kind of thing you are trying. While writing a custom adapter and serializer used to be an advanced topic it is now really straightforward.
At present the best resources are:
the guides
the ember-data transition doc
discussion on migrating to the beta
What's the relationship between RESTAdapter and JSONSerializer?
An adapter is an object that receives requests from a store and translates them into the appropriate action to take against your persistence layer. The RESTAdapter is an adapter that knows how to talk to a restful HTTP server by transmitting JSON via XHR.
A serializer is responsible for serializing and deserializing a group of records. The JSONSerializer is just a serializer that knows how to read and write JSON.
With new ember-data it should be pretty straightforward to extend/configure the rest-adapter and json serializer to speak to a CouchDB backend. Have a look at rest-adapter-and-serializer-configuration for some examples.

Related

Django Channels 2.x or Ajax?

I have a jQuery dataTable, with lots of data(10000+ rows), which can be used/updated in the real time from lots of users and I need that table to be refreshed and up to date all the time. I've tried with Ajax calls on 1 second, and I figured that that's not good, since every user is sending Ajax request every second * 50 or more users, and I think that there must be a better solution. I've been thinking to use Django Channels, or something similar(?) and i was wondering is that possible? Basically I need to set up some kind of listener on the model(database), and to pull the new data on change(that is almost every second). I would love to here an opinion from someone who has more experience than I do. Thank you in advance.
Ps. I've been told to use web sockets for that.
In short yes web socket would be the suggested way to do this.
If all the updates to the models that you need to subscribe to are being made through Djangos ORM.
I would suggest looking into using (or be inspired by) DjangoChannelsRestFramework as a starting point for subscribing to multiple models in your db.
This library is set up to let you subscribe to multiple object types over a single web socket connection and get ws messages whenever they objects change. It also provides some tools to let you re-use your existing DRF views over the web socket.
Disclaimer: I am the author of the DjangoChannelsRestFramework.

Send POST request from ember to specified URL

I am new to full stack development, and having an issue with a web application I'm working on for my employer. I was tasked with creating a fairly simple application that we can scale over time. For now all that it needs to do is take data from one of our databases, and pass it to a front end application. Using this front-end app our workers should be able to double check the information passed in, and make sure it has been properly translated to a new format. After it is translated I want to send an HTTP POST request to our new systems back-end and have it add this new data via the REST API. Essentially it's an application that was used for practice to get me more acquainted with full stack development while making an effective tool to transfer mass data from one system to another. I can't seem to figure out how to set up something in ember.js to send that POST request to somewhere other than my back-end though.
I believe after re-reading the page on the ember.js site I found my answer. Sorry for posting a question that was already answered elsewhere. It was asked after a while of googling and not finding what sounded right. Just needed a day to let my brain reset I guess. In any case, if somebody else stumbles upon this post and (like me) wasn't comprehending at the time, the answer lies here: https://guides.emberjs.com/v1.10.0/models/connecting-to-an-http-server/
You simply create a new adapter with the host you want to send requests to. Then you can create a new model in my case to serialize the data in a way the host will understand what you're trying to transfer to it. This will allow for data migration between sources like I desired. Sorry again for the unnecessary post, but hopefully it helps someone else in the future.

Creating functional classes in Django that provide deployment pipeline functionality

I am learning Django, so please correct any issues with my way of thinking here.
To start, I am using the Django Rest framework and I'm not interested in just creating a list of items, which is all that I can find examples of on the entire Internet...
I will have some pretty large functional classes that will POST and GET data to and from a pipeline server (TFS to be specific) and obviously, I'll need to insert this logic into a file within my app, I'm not just displaying things from my database here.
So, my question is, where does this go within my app? my understanding is that the "Django way" is to keep models thick.. does that mean that all code logic to make requests and interact with the pipeline server should end up in my models.py?
It's kinda frustrating that everyone else seems to just be listing furniture or some other sales item from their database. Which does not really help me very much... I need to know what a very large web app would look like (one that has a lot of logic and not just a stupid list of red and blue chairs).

EMBER.JS Define models if I only need to read?

Is there any utility in defining models in Ember if I am only going to read from the server?
Yes there is. Modelling your frontend to be similar to the backend will always be helpful.
The plus points I can think of are
Hassle free handling of relationships.
Caching of results in the store would save on server calls.
Writing back to the server becomes easy if you suddenly need that.
Selective data loading with the {async:true} option in relationships. Load only what you need.
Check out this link http://emberjs.com/blog/2014/03/18/the-road-to-ember-data-1-0.html for more information.

How can I write Ember.js applications with HAML, SASS, and CoffeeScript?

I don't want to be tied to any back-end framework and just want to write a full client-side Ember.js application that gets its data via various JSON APIs.
I haven't yet found a way to pre-compile writing a haml/sass/coffeescript application in a way that is satisfactory for my liking.
You might want to check out brunch.io it has various skeletons to get started, is extensible via bower and takes care of everything that used to be a pain in the neck like minification etc.