JavaScript EmberJS: is it possible to save only modified objects?

I have a small and quite standard application that:

  • Fetches objects from the server
  • Renders the objects and allows some editing on them. If it is important, this editing only affects DS.hasMany attributes.
  • Offers a saving back to the server (it should not happen automatically, only on user request)

The app controller handles a save event, and there I store the stuff. The code looks like this:

import Ember from 'ember';

export default Ember.Controller.extend({
    actions: {
        save() {
            this.store.peekAll('object').forEach(obj => {
                obj.save();
            });
        }
    }
});

This issues a PUT request for each object locally loaded. It works fine, but it is a little bit of brute force. Instead, I would like to save only the modified objects.

I have tried with dirtyType, but it returns undefined inside of the .forEach, and also hasDirtyAttributes, but it returns false always.

I could build my own cache of modified objects, but that would be a lot of work and error prone. Is there any standard way of handling this situation? thanks in advance.

Answer:1

I'm looking for a list of time zones that corresponds to major cities. Like what java.util.TimeZone can provide. I mean, I want to resolve the America/Los_Angeles identifier to UTC-8:00 in javascript. ...

I'm looking for a list of time zones that corresponds to major cities. Like what java.util.TimeZone can provide. I mean, I want to resolve the America/Los_Angeles identifier to UTC-8:00 in javascript. ...

  1. timezones list json

Please look at below codes: Case 1: var a = { b: function(){ console.log(a) }, c:1 }; Case 2: var a = { b:a, c:1 }; Now when I write this : a.b() // for first console....

Please look at below codes: Case 1: var a = { b: function(){ console.log(a) }, c:1 }; Case 2: var a = { b:a, c:1 }; Now when I write this : a.b() // for first console....

  1. javascript object accessing
  2. javascript object accessing properties
  3. javascript object accessing values
  4. javascript accessing object properties with variables
  5. javascript accessing object properties dynamically
  6. javascript accessing object keys
  7. javascript accessing object in array
  8. javascript accessing object properties by index
  9. javascript accessing object fields
  10. javascript accessing object elements
  11. js accessing object properties
  12. js accessing object values
  13. js accessing object
  14. basic javascript accessing object properties with variables
  15. basic javascript accessing object properties with bracket notation
  16. basic javascript accessing object properties with dot notation
  17. basic javascript accessing object properties with variables freecodecamp
  18. basic javascript accessing object properties with dot notation freecodecamp
  19. accessing javascript object variables
  20. accessing javascript object in html

I get this error from the TrackballControls.js: this.domElement.addEventListener is not a function This occurs when I assign the TrackballControls to a DOM: // 'container' is a variable var ...

I get this error from the TrackballControls.js: this.domElement.addEventListener is not a function This occurs when I assign the TrackballControls to a DOM: // 'container' is a variable var ...

I'd like to augment all Objects in my Node.js application with a logging function, such that each object can call this.log or have its log function referenced by thatObject.log. I see a number of ...

I'd like to augment all Objects in my Node.js application with a logging function, such that each object can call this.log or have its log function referenced by thatObject.log. I see a number of ...