Skip to main content

Ember data load model using findQuery

Loading Ember model in route is as simple as:

App.PostsRoute = Ember.Route.extend({
  model: function(params) {
     return this.store.find('post', params.post_id);
  }
});

But when loading model using findQuery then

App.PostsRoute = Ember.Route.extend({
  modelfunction(params) {
     return this.store.find('person, {name: params.username}).then(function(result){

        return result.get('firstObject')

     });

  }
});


findQuery return Array therefore select firstObject from Array, Remember to return Array from api for '/persons?name=test_name' url.

Comments

  1. I'm glad to hear that it solved your problem. Happy Coding :)

    ReplyDelete

Post a Comment

Popular posts from this blog

Resolve OpenSSL::SSL::SSLError on Yosemite

If you are using rvm installed ruby on Yosemite  OSX  and getting error : OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed then reinstalling ruby with ` --disable-binary` may fix this Issue. rvm reinstall 2.1.2 --disable-binary  Reason: Ruby installed with packaged binary in rvm has OpenSSL path: /etc/openssl  Path of installed openssl is :  /usr/local/etc/openssl To check openssl directory: > irb > require 'openssl' > "SSL_CERT_DIR: %s" % OpenSSL::X509::DEFAULT_CERT_DIR

Software Engineering Vs Programming

When I was growing up,   Software Engineer and Programmer seems same term to me. Now after working a couple of years as a Software Engineer I think I can distinguish between the two terms.  Programming is a small part of Software Engineering.  Software Engineering include Understanding Requirement  Designing Software Organising code  Testing Software  Collaborating with other software engineers Writing good code is essential skill for being a Good software engineer but you can not neglect others skills as they are equally important for building good product. I read something similar in Software Engineering subject during my graduation, but none of the above make sense than. I think reading about software engineering is not the great way to learn about it instead build a lots of software and you will get a grasp of software engineering. What text books do not tell you about Software Engineering is : U...

Creating an ember cli component addon for javascript library

Create addon with generator command ember addon <addon-name> example: ember addon ember-cli-holderjs Add bower dependency  create blueprint to install dependency  ember g blueprint <addon-name> example: ember g blueprint ember-cli-holderjs Two files will be created installing blueprint   create blueprints/.jshintrc   create blueprints/ember-cli-holderjs/index.js Edit blueprints/<addon-name>/index.js Add afterInstall hook to add javascript library package to bower.json afterInstall: function(options) {     return this.addBowerPackageToProject('holderjs', '2.9.0');   } Generate component ember g component <addon-name> example: ember g component ember-cli-holderjs This will create following files installing component   create addon/components/ember-cli-holderjs.js   create addon/templates/components/ember-cli-holderjs.hbs installing ...