GithubHelp home page GithubHelp logo

store.findOne ? about data HOT 12 CLOSED

emberjs avatar emberjs commented on May 23, 2024
store.findOne ?

from data.

Comments (12)

pixelcort avatar pixelcort commented on May 23, 2024

I would like to see this as well.

Workaround is to observe the array and take its firstObject once it comes in.

from data.

garth avatar garth commented on May 23, 2024

How about adding a wrapper for findMany that returns a single object without ID, so that you can push it into the view immediately, then hold a reference to it until the ajax callback and populate with the first record returned.

The key issue for me is not having to manage the callbacks (plumbing) in my app logic.

from data.

wycats avatar wycats commented on May 23, 2024

Is the rationale for this feature a singleton resource in general?

from data.

garth avatar garth commented on May 23, 2024

I think that there are lots of cases where I want to get one instance of a model and I know it's there but I don't know the ID.

For example: in a calendar system I may want to get today or this month, I know they exist (and if they don't I will create them server side as part of the request) but I don't know their ID.

And I want to insert the single item into the view, not a collection. Of course there are workarounds, but just not so convenient.

from data.

wycats avatar wycats commented on May 23, 2024

Makes sense.

from data.

wagenet avatar wagenet commented on May 23, 2024

For now, you can use jQuery.ajax to hit the endpoint and then load into your store.

from data.

wagenet avatar wagenet commented on May 23, 2024

You can also use a fake id, such as 'singleton' and have you adapter handle this case. Judging by #58 this is not something we have explicit plans to support, though a PR to hide the 'singleton' id might be acceptable.

from data.

lukaiser avatar lukaiser commented on May 23, 2024

What's the status of this request? I don't really get it. I'm absolutely in favor of it. In my case, I have a find query App.MyModel.find({q: "test"}) witch always returns only one model (not always the same). Currently I have to use the same workaround as described in Issue #385. A fake ID isn't working, because it's a query. And using jQuery.ajax is in my opinion totally the wrong approach, because it's a parallel structure and I can't just switch my adapter, if I want to.

from data.

darthdeus avatar darthdeus commented on May 23, 2024

This is also related to #551

from data.

pdf avatar pdf commented on May 23, 2024

So, wait, @wycats said this makes sense, and this and related issues (#58 #97 #385 #393 #551 possibly others) keep coming up, yet this seems to get rejected out of hand... is there some way to find consensus?

from data.

jdivock avatar jdivock commented on May 23, 2024

Chiming in that I find this to be an odd oversight. I just spent a good deal of time trying to hack up a way to load a simple currentUserProfile . . . which is just that, the profile of the current user. It has no idea, just a series of value related to the user returned from the middle layer.

Backbone and other frameworks allow for an singular instance that is just a model and not a collection, I find it odd that this feature keeps getting deferred.

from data.

wagenet avatar wagenet commented on May 23, 2024

See #551.

from data.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.