Comments (11)
I am unsure if it is directly related, but I noticed.
https://github.com/firebase/emberFire/blob/master/src/data.js#L181 doesn't enqueue an actual error object, which likely is resulting in a poor error message.
This is due to crappy error logging in the router: https://github.com/emberjs/ember.js/blob/master/packages_es6/ember-routing/lib/system/router.js#L525
opened an issue: emberjs/ember.js#4691
But in general it is best practice to reject with error objects
from emberfire.
@jrhe I went to https://emberfire-test.firebaseio.com/posts.json in the browser and it looks like your Firebase doesn't have any data at the /posts
location
@stefanpenner I'll update that so it throws an actual error.
from emberfire.
@aputinski Does that mean you have to bootstrap your firebase with some data? If not, how are you then supposed to handle empty collections?
from emberfire.
Luckily I haven't hit this problem yet because I'm accessing a non-existing child collection through a record that does exist in firebase and it works well. But I see a future use case where I will hit this problem. I went through the code to understand why it was working in my case and interestingly I noticed that if you access a non-existing collection (could be anything really) through a parent record like so this.modelFor('post').get('comments')
emberFire gets the post
and then emberData converts comments
attribute to an Ember.Array
which in turn converts an undefined
to an empty array.
Usually it's a good practice to return empty objects as opposed to null
or undefined
, however, how would you detect that resource doesn't exist in that case? If one chooses to display an error message for example.
You can handle the rejection like so,
var route = this;
return new Ember.RSVP.Promise(function(resolve, error) {
resolve(route.store.find('post'));
}).then(function(value) {
return value;
}, function(reason) {
return [];
});
from emberfire.
simplification of @mbykovskyy example
route.store.find('post').catch(function(reason) {
// check if reason tells us it was just "not found"
return [];
});
from emberfire.
Nice one @stefanpenner!
from emberfire.
@stefanpenner would there be any harm in returning an empty array in the adapter if no data was found instead of rejecting?
https://github.com/firebase/emberFire/blob/master/src/data.js#L257
from emberfire.
@aputinski I am unsure
from emberfire.
I knew that I had no data but I couldn't figure out how to create it
correctly through the GUI and I assumed that that it would have created the
collection if I tried to create a record.
On 11 April 2014 17:54, Stefan Penner [email protected] wrote:
@aputinski https://github.com/aputinski I am unsure
Reply to this email directly or view it on GitHubhttps://github.com//issues/39#issuecomment-40225338
.
from emberfire.
@aputinski Your fixes work well.
from emberfire.
will using {{link-to 'HOME' 'home'}} break an app? also is this discouraged?
should I be using {{#link-to}}HOME{{/link-to}} instead. I'm wondering if this is the reason my app seems to break
from emberfire.
Related Issues (20)
- This seems to throw an error HOT 2
- Realtime: how to subscribe to multiple documents HOT 15
- Steps for local-setup lead to non-functional dummy app HOT 2
- Does emberfire v3 realtime database adapter work at all? HOT 7
- store.queryRecord broken with query-only HOT 2
- Type Error: firebase-app.ts HOT 2
- Realtime Updates not working HOT 8
- fastboot, ember simple auth and emberfire dont work each other HOT 2
- error querying firestore in fastboot mode HOT 1
- Firestore adapter reference options order
- Emberfire v3 bug in the firestore adapter
- Bug in firestore: Cannot read property 'replace' of undefined HOT 5
- Using `include` in findRecord throws error HOT 1
- subcollections implemented in a way that prevents multiple hasmany relationships with the same model
- FirestoreAdapter Error while processing route: index the adapter could not find the resource HOT 2
- Session.isAuthenticated is not getting updated? HOT 5
- adapter.fetch is not a function when using TORII for Auth in 3.0.0-rc6 HOT 1
- Potential Security Issue
- @jamesdaniels, please consider ember-adopted-addons program HOT 1
- For Anyone Struggling with hasMany relationships with Firestore
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emberfire.