My alternative to ember data


#1

Hi Guys.

I’ve built a reasonably simple alternative to ember-data called which I’d like to throw out there:

It takes a slightly different approach by not really focusing on relationships, but more on controlling how and when data gets loaded into an object by letting you define “lazy” and “partial” fields.

Like a few people, I’ve had some difficult experiences with ember data so decided to make something which would provide me with the features I want for my current projects. It may not service everyone’s needs and is not intended to be as ambitious as ember data but would be interested to hear what people think.

Cheers

Charlie.


#2

hey cool…

does it default to REST ?


#3

Hi Charlie, great job on this!

I have a question though, is it possible to do something like:

App.Organization = Emu.Model.extend({
  name: Emu.field('string'),
  projects: Emu.field('App.Project', {collection: true, lazy: true})
});

App.Project = Emu.Model.extend({
  name: Emu.field('string'),
  organization: Emu.field('App.Organization')
});

App.Organization.find(1).get('projects').createRecord({
  name: 'Foo'
});

Where the adapter would make a call to:

POST /organization/:id/project

My workaround would be to create the project with an organizationId then reload the projects of the organization. Is there a way to do this in one call?

Thanks!

Charles


#4

Yeah, if you don’t pass the store an adapter uses the rest one


#5

Hi Charles,

In order to save the new record you’d have to do

project = App.Organization.find(1).get('projects').createRecord({
  name: 'Foo'
});
project.save()

Then, the adapter should make a call to

POST /organization/:id/project

However, I tested this out and it actually makes a call to

POST /project

Which isn’t right so I’m going to fix that: https://github.com/charlieridley/emu/issues/22

Glad you like what I’ve done so far, thanks.


#6

Just to let you know I fixed that issue so the latest version on github. This integration tests demonstrates the fix:


#7

Awesome! Thanks for the quick fix!


#8

Hey everyone, I’ve also been working on a model library. It’s called Ember Model: https://github.com/ebryn/ember-model

Would love some help :slight_smile:


#9

Hey Erik. This looks great, I’ll have a play.