Need to create REST API with `many-to-many` relations in MySQL

Hello all!

I’m very new to ember, but going to introduce to my colleagues how it’s possible to create a RESTful APIs in Ember.

I think I have only this week to show my test results, so I’m in rush.

UI is the low priority.

I need create a RESTful APIs, with the URLs:

  • <url>/api/teachers/ - the list of all teachers
  • <url>/api/teachers/:teacher_id/students/ - the list of all students for this given teacher
  • <url>/api/students/ - the list of all students
  • <url>/api/students/:student_id/teachers - the list of all teachers for this given student

Sample image here

I have some ebooks for beginners to start with, but I don’t have resources which shows how to make RESTful APIs with database that have many-to-many relations like in this example.

Can you please please give me some orientation on solving this problem?

Thanks in advance.

PS: Not sure if I had to post this in the Ember-data category…

I’m very new to Ember as well, so hope I’m correct, but Ember is a client-side framework so you will not use Ember to create a REST API as such, you will only use Ember (or Ember-Data) to consume a REST API created in Rails or PHP or some other server-side technology.

See this post for a full-stack solution that might help with creating the REST API side of things on the server: Ember + PHP with JSON API

1 Like

I’ll add a bit to @novascape You just need to follow installation instruction for Limoncello Collins which is a sever side (5-10 mins maybe) and install client for this demo server app Limoncello Ember (3 mins probably) and you good to go.

The server and client support

  • CRUD operations for a few sample data models and Users.
  • Cross-origin requests (CORS) to API server.
  • Server login (Basic Auth) and API authentication (JWT Bearer).

Feel free to ask your questions if any.

1 Like


I’ve installed everything following the instructions.

It has no any reaction when I try to default login ( at localhost:4200/login .

Another interesting I noticed. When you access localhost:4200 from Chrome,

it shows Home and Login links in the upper corner, but for Firefox, it’s not showing up :wink:

@askar I’ve updated git tags and it should work now. You need to create server side again. The full instruction below

in console #1

  • mkdir test && cd test
  • composer create-project neomerx/limoncello-collins --prefer-dist && cd limoncello-collins/
  • touch storage/database.sqlite && php artisan migrate --force && php artisan db:seed --force
  • php artisan serve --port=8888

in console #2

  • cd test
  • git clone && cd limoncello-ember
  • npm install && bower install && ember s

in browser

In my Firefox and Chromium both login pages look identical

1 Like

@neomerx Hi!

It doesn’t create a new item.

For example, here’s a screenshot Dropbox - File Deleted


It seems it was creating, it just wasn’t changing the page. But, I assume there’s some issue as per screenshot.


I also don’t see at the moment its realtimeness. I assume, when I create any item on Chrome, I should see how it appears in realtime on Firefox…

@askar It’s a simple demo so pushing notifications is not there. That’s why you don’t see realtimeness.

The errors on the screenshot are weird. It looks like the browser doesn’t send CORS headers and logs its own behavior as and error. I guess it might be an issue related to browser settings.

1 Like