Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FirestoreAdapter Error while processing route: index the adapter could not find the resource #620

Open
ghost opened this issue Jul 15, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 15, 2020

Version info

e.g.
DEBUG: -------------------------------
DEBUG: Ember      : 3.19
DEBUG: Ember Data : 3.19
DEBUG: Firebase   : 7.16.0
DEBUG: EmberFire  : 3.0.0-rc.6
DEBUG: jQuery     : 3.5.1
DEBUG: -------------------------------

Description

I am building an application that uses subcollections, and I received the error given in the title when trying to use store.findRecord(). A generic form of my application is someone having a catalog of albums and the songs on each album with the following structure:

users/{userId}/albums/{albumId}
              /songs/{songId}

The document userId has no fields, only the two subcollections. The album document has fields with related information, including a field for the uid generated by Firebase. The song document is very similar, with the addition of a albumId field to indicate which album the song is on, creating a one-to-many relationship between an album and various songs. I use the following models for the user, album, and song:

User Model

import Model, { hasMany } from '@ember-data/model';

export default class UsersModel extends Model {
  @hasMany('albums', { subcollection: true }) albums;
  @hasMany('songs', { subcollection: true }) songs;
}

Album Model

import Model, { attr, belongsTo } from '@ember-data/model';

export default class AlbumsModel extends Model {
  @belongsTo('users') user;
  
  @attr('string') id;
  @attr('string') name;
  @attr('string') yearOfRelease;
  @attr('string') artist;
  @attr('string') label;
}

Song Model

import Model, { attr, belongsTo } from '@ember-data/model';

export default class SongsModel extends Model {
  @belongsTo('users') user;
  
  @attr('string') albumId;
  @attr('string') id;
  @attr('string') title;
  @attr('string') length;
}

I am attempting to create a page at index that will show the albums the user has in their library after authenticating. I use this route to try and make that query:

app/routes/index.js

import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

import firebase from 'firebase/app';

export default class IndexRoute extends Route {
  @service session;
  @service firebaseApp;
  
  //async model() {}
  model() {
    return this.store.findRecord('users', this.session.data.authenticated.user.uid);
  }
}

and use this template to see if data is coming through:

app/templates/index.hbs

<h1 class="text-center mt-2">Albums</h1>

{{#each @model.albums as |album|}}
  <h2>{{album.name}}</h2>
{{/each}}

When I run ember serve to try and view the data, I get the error "Error while processing route: index the adapter could not find the resource". I based this structure off of the example app given in the repository, which has a relatively similar structure. Since I cannot see the underlying Firestore structure, however, it very well could be an issue in my setup.

Steps to reproduce

  1. Create a Firestore database with a content-owner structure as specified in my description above
  2. Create create the above models, route, etc.
  3. Serve the program

Expected behavior

To see a list of the album names

Actual behavior

An error with the adapter not being able to find the resources.

@12finger
Copy link

12finger commented Oct 26, 2020

hey @BladeFrisch , have you checked out: #614 ?
just try @charlesfries's patch if you're using the Firestore serializer,
( or @zoltan-nz's code for the older RealtimeDatabaseSerializer )

it got me going again!

@ghost
Copy link
Author

ghost commented Nov 12, 2020

Thank you for the info, but we ended up re-writing the app in Angular. We needed something quickly. I will check this out for future projects though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant