Questions tagged [ember-data]

ember-data is a data persistence extension for the Ember.js framework.

ember-data
Filter by
Sorted by
Tagged with
8 votes
1 answer
3k views

Ember Data: Overriding Save method

Hello Ember Data World, I have been studying custom adapters attempting to figure out how to override the save method. From my understanding, it seems like you need to do something like this: DS....
joker1979's user avatar
  • 181
8 votes
4 answers
3k views

Adding item to filtered result from ember-data

I have a DS.Store which uses the DS.RESTAdapter and a ChatMessage object defined as such: App.ChatMessage = DS.Model.extend({ contents: DS.attr('string'), roomId: DS.attr('string') }); ...
rlivsey's user avatar
  • 2,124
8 votes
1 answer
2k views

Ember.js: How can I prevent transition on dirty model with async confirmation?

I have a pretty common situation: there is a dirty model and I want to show a confirmation if user tries to transition to any other route. I have something like this to work with window.confirm ...
Anthony Hell's user avatar
8 votes
1 answer
19k views

Iterating over Ember.js ember-data Record Arrays

I've been beating my head against this problem all day, and I feel like I'm close to a solution but just can't quite make it happen. I'm using Ember.js with Ember-Data and the Fixtures adapter, ...
Ben's user avatar
  • 581
8 votes
1 answer
5k views

How to acess the length of a find() result in Ember.js

THE ANSWER TO THIS QUESTION AND THIS WHOLE QUESTION IS OBSOLETE. EMBER DATA HAS CHANGED A LOT. READ THIS: http://guides.emberjs.com/v1.11.0/models/ I have this little Ember application: window.App = ...
ohcibi's user avatar
  • 2,609
8 votes
1 answer
1k views

Self-Join with Ember-Data

Does anyone have any suggestions on how to manually create a self-join relationship using ember-data? If, for example, a user had many followers (other users), what would be the simplest way to ...
Han's user avatar
  • 1,293
8 votes
2 answers
3k views

Returning record(s) after store pushPayload call

Is there a better way to return the record(s) after DS.Store#pushPayload is called? This is what I'm doing... var payload = { id: 1, title: "Example" } store.pushPayload('post', payload); return ...
tonycoco's user avatar
  • 531
8 votes
1 answer
3k views

Emberjs: How to filter by more than one property at once

Below I am filtering by a single property sure, but how do I filter by another one in one go? That is, without providing the user with a drop down containing different search options Example: My ...
KALBB's user avatar
  • 105
8 votes
3 answers
4k views

Return count of total rows in ember data `find` or `findAll` request

I need to know how many rows of a specific resource (App.User) exist in total. I tried to return it in response, but Ember complains about not mapped properties and is expecting only array of records ...
korCZis's user avatar
  • 550
8 votes
1 answer
1k views

Understanding Ember Views

I'm looking for some clarification on views in Ember.js Coming from a rails background and I'm trying to ignore any preconceptions. From what I understand of the ember framework there are 5 ...
Matthew Sumner's user avatar
8 votes
1 answer
3k views

Setup a callback after a transaction has committed

I'm trying to achieve something that I guess has a simple answer but somehow I can't find it reading the source code of ember-data. I would like to trigger an action after a particular set of ...
josepjaume's user avatar
8 votes
1 answer
5k views

Ember-Data callback when findAll finished loading all records

With ember-data I'm loading all records of a model with: App.adapter = DS.Adapter.create({ findAll: function(store, type) { var url = type.url; jQuery.getJSON(url, function(data) { ...
Panagiotis Panagi's user avatar
8 votes
3 answers
5k views

Ember.js Rest Adapter: mapping JSON with no root (.NET Web API)

I have an existing service written with the .NET Web API. As an example, this service returns JSON in the following format: [ { "id": 1, "name": "John" }, { "id": 2, "name": "Jane" } ] However, ...
Tyson Nero's user avatar
  • 2,078
8 votes
2 answers
2k views

Partial update in Ember-Data?

Imagine a bug tracker. Each ticket contains a lot of data. Now the status of a few tickets from a long list of tickets is updated. App.Ticket = DS.Model.extend({ id: DS.attr('number'), ...
stephanos's user avatar
  • 3,339
8 votes
2 answers
2k views

Ember choking upon encountering large data sets

Looking for a solution to an issue caused by large data sets forcing Ember to lock up the browser while it tries to process the data. For pagination, I'm using tchak's handy pagination mixin to ...
Marco's user avatar
  • 4,365
8 votes
2 answers
792 views

Save multiple model at once, in bulk

I know this subject has already been discussed around stackoverflow and other forums, but I cannot find the right way to do it. I have a model called "post" which contain post information (user, ...
alexmngn's user avatar
  • 9,267
8 votes
3 answers
3k views

How to handle 404 of Ember Data in route?

In my route I have a method that tries to request a list of models from the server model: -> App.MyModel.find projectId: (@modelFor "project").id Now obviously sometimes this might ...
stephanos's user avatar
  • 3,339
8 votes
1 answer
2k views

How to create has_and_belongs_to_many relationship with Ember.js & ember-data?

Is it possible to create a hasAndBelongsToMany relationship with Ember.js & ember-data? Edit: Added ActiveRecord model examples to clarify. class Project < ActiveRecord::Base ...
David's user avatar
  • 1,330
8 votes
1 answer
921 views

EmberJS embedded items in payload JSONAPI

Ember : 1.13.3 Ember Data : 1.13.5 jQuery : 1.11.3 I am trying to send a JSON payload using ember-data from my EmberJS client to my server. I want to send the entire object graph to the ...
Asagohan's user avatar
  • 593
8 votes
2 answers
3k views

remove child from hasMany relationship

How do you remove a child from a hasMany relationship without deleting the child? I have tried setting the foreign_key of the child to null. I have also tried using removeObject on the parent ...
Aaron Renoir's user avatar
  • 4,343
8 votes
2 answers
2k views

Ember Data: create Model without store

Is there a way to create a DS.Model object without using store.createRecord ? EDIT maybe I need to give some context. I am writing an Ember Addon that has a few model that are not bridged through ...
Sang Park's user avatar
  • 382
8 votes
1 answer
3k views

How to use Ember Data with Nested Resources

My application backend has several resources. A model is exposed for each resource. The entry point to all other resources is through the User model. What I mean is, given a User we can find BlogPost....
Code Poet's user avatar
  • 11.3k
7 votes
2 answers
6k views

Passing parameters to save()

Is it possible to pass parameters like this? I need to pass some information that is not part of the model itself. myModel.save({site : 23})
jax's user avatar
  • 38.3k
7 votes
4 answers
7k views

How to get store name of Ember Data model

How can I determine the "store name" (not sure what the proper terminology is) for a given ED Model? Say I have App.Payment, is there a store method that let's me look up its corresponding name, i.e. ...
chopper's user avatar
  • 6,679
7 votes
4 answers
8k views

Ember.js REST Adapter without JSON root

The Ember.js REST Adapter expects the JSON to be returned as: { "person": { "first_name": "Barack", "last_name": "Obama", "is_person_of_the_year": true } } But my API ...
Richard's user avatar
  • 3,969
7 votes
1 answer
4k views

What is the difference between Adapter and Fixture Adapter and REST Adapter, in ember-data?

What is the difference between Adapter and Fixture Adapter and REST Adapter, and when to use each one?
ladyboo's user avatar
  • 137
7 votes
2 answers
3k views

Ember Data: Get a Model in the Console

I have the simplest possible Ember app in this JSBin. All I'm trying to do is find a model. Based on other SO questions, I've tried the following. App.User.get('store').find('user', 1); App.User....
nickcoxdotme's user avatar
  • 6,657
7 votes
3 answers
6k views

How to delete Ember Data record by its ID

With Ember Data, I would like to know how to delete a record given that I know its id.
HaoQi Li's user avatar
  • 12.2k
7 votes
1 answer
4k views

Ember Data not finding model, while it is clearly there

I have as many others upgraded my ember app to the newest version of anything, but after having upgraded, my app is still not working. I have simplified a lot, and it boils down to my route. My route ...
Jan Dragsbaek's user avatar
7 votes
1 answer
3k views

Display the first item in hasMany ember relationship in handlebars template

I need to display the first item in an hasMany relationship Basically a thread could have more than 1 author but I need to display only the first one in a particular template I've the following json ...
Fed03's user avatar
  • 585
7 votes
1 answer
5k views

How to delete all records associated with an ember model without clearing local Storage?

I have extended the program given in this stackoverflow answer to have a program that deletes all the records all at once. However, the deletion happens only in batches and does not delete everything ...
user2431285's user avatar
7 votes
2 answers
6k views

Many to Many Relationships with Ember, ember-data and Rails

I am having an issue with trying to save many to many relationships in Ember.js using ember-data and rails. The association works fine on the ember side of things, however when I try to commit the ...
McPants's user avatar
  • 83
7 votes
1 answer
2k views

Ember 1.0.0: Ember.State has been moved into a plugin: https://github.com/emberjs/ember-states

I am migrating an Ember rc7 project to Ember 1.0.0. I have this unusual error: Ember.State has been moved into a plugin: https://github.com/emberjs/ember-states I have the error only if I use a ...
cyclomarc's user avatar
  • 1,992
7 votes
2 answers
2k views

Why do I need to "reopenClass" to set the url for an ember-data model?

I found that if I try to include the url in the original definition of an ember-data model it blows up in my REST adapter but if I simply "reopenClass" it's fine. What is the technical reason behind ...
Toran Billups's user avatar
7 votes
3 answers
2k views

Ember.js: How to integration test components that interact with ember-data models

I'm building a relatively straight-foward comment-list component. I want to pass in the commentable model (say a Post) and have the component take care of creating, editing, deleting comments. Right ...
mattmcmanus's user avatar
  • 1,786
7 votes
2 answers
3k views

Rails-style polymorphic model in ember-data

If I have the following models in Rails, how would I represent this in Ember/Ember Data? class Attachment < ActiveRecord::Base belongs_to :user belongs_to :attachable, polymorphic: true end ...
Kevin Ansfield's user avatar
7 votes
4 answers
5k views

How can I clone an Ember Data record, including relationships?

I've figured out that I can clone an Ember Data record and copy its Attributes, but none of the belongsTo/hasMany relationships are cloned. Can I do this somehow if I don't know what relationships ...
Kerrick's user avatar
  • 7,470
7 votes
1 answer
5k views

Find record from belongsTo association in Ember.js

How can I get the associated record from an Ember model? Or: how to get the record from the Promise Object? Customer model Docket.Customer = DS.Model.extend({ name: DS.attr('string'), ...
Slevin's user avatar
  • 4,364
7 votes
1 answer
4k views

How to do filter in the new Ember Data? Also how does filter compare to find in the new Ember Data

What's the equivalent of App.Person.filter(function(e){return e.get('age') == 30}) in the new Ember Data? In the old Ember Data, App.Model.filter produced a different type of object versus App....
HaoQi Li's user avatar
  • 12.2k
7 votes
1 answer
3k views

Uncaught Error: Assertion Failed: You may not set `id` as an attribute on your model

Entire error: Uncaught Error: Assertion Failed: You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from App.Plan Ember Model: ...
Bogdan Zurac's user avatar
  • 6,440
7 votes
1 answer
6k views

Error "Assertion Failed: Expected an object as `data` in a call to `push`/`update`" when trying to normalize and push

In my Ember app, I get notifications from a websocket. When the websocket receives a message (encoded as JSON), I want to push it into the store. Here's my code so far: console.log('About to normalize'...
Marc-François's user avatar
7 votes
1 answer
5k views

what's the difference between find, findAll and findQuery in ember-data

What is the difference between find, findAll and findQuery in ember-data?
Aaron Renoir's user avatar
  • 4,343
7 votes
4 answers
6k views

add/delete items from Ember Data backed ArrayController

I'm using an ArrayController in my application that is fed from a Ember Data REST call via the application's Router: postsController.connectOutlet('comment', App.Comment.find({post_id: post_id})); ...
outside2344's user avatar
  • 2,085
7 votes
2 answers
3k views

How to deal with heavy-load processing of displayed data in the browser

The context We have an Ember-based app which handles large amount of structured data (Business process models). Important! We would really like to keep our app offline-able, as far as possible. The ...
Mike Aski's user avatar
  • 9,187
7 votes
1 answer
964 views

failed to get embedded's object property using ember.js with ember-data

I'm new to ember, and try to understand how it works. I've defined a store with a fixturesAdapter as adapter (rev 7). I've defined two models: App.Tag = DS.Model.extend({ name: DS.attr('string'...
Nicolas Marigny's user avatar
7 votes
1 answer
2k views

Ember Octane Upgrade How to pass values from component to controller

Upgrade from Ember <3.15 to >=3.15. How do I pass form values from a controller into a component? I cannot begin to explain the number of diagnostic combinations attempted and their ...
J Weezy's user avatar
  • 3,687
7 votes
2 answers
2k views

Ember Data: model and hasMany submodels not persisting

I have a problem similar to this stack overflow question, except the answer doesn't seem to be working. I have a form in which the user creates a container module with a variable number of submodels. ...
ansorensen's user avatar
  • 1,316
7 votes
3 answers
2k views

Dynamically fill models with more detailed data in emberjs

I'm a bit stuck with implementing master-detail views in emberjs. Most of my views have a master-view which is just a list of titles. Then, a user can click such title and he/she gets an overlay ...
polyclick's user avatar
  • 2,713
7 votes
1 answer
1k views

Retain fixtures with multiple adapters per Ember environment

Although the natural progression would replace the fixture adapter with another adapter, I'd like to retain fixtures for development environment while leveraging a different Ember data adapter for ...
Jason Sturges's user avatar
7 votes
1 answer
4k views

Nested resources in ember.js, adding comments to a post with fixture data

I'm trying to write a simple blog with Ember. I can't figure out how to nest comments resource inside the post resource. (I used ember-cli to generate the app) /app/router.js var Router = Ember....
brownie3003's user avatar