0

I am trying to write a nested query, that I think can look like this:

store.find('logs/by_date', '2016-11-02/user%40example,com')
     .then(result => console.log(result));

Where the ID is not just an ID, but a nested location in Firebase. Is this possible with js-data?

When I try to run the query above I get the error:

[Error: [Mapper#createRecord:props] expected: array or object, found: string http://www.js-data.io/v3.0/docs/errors#400] }

Based on the documentation at http://api.js-data.io/js-data-firebase/3.0.0-beta.2/Adapter.html#find__anchor - the ID can be a string/number

I am using node.js and my setup for the store is as follows:

store.defineMapper('logs/by_date');

I can't really setup a mapper for each date, so how do I achieve this?

My data is structed in firebase as

{
  logs : {
    by_date : {
      '2016-11-02' : {
        'user%40example,com' : [
          { msg: "log error 1" },
          { msg: "log error 2" }
        ]
      }
    }
  }
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
filype
  • 8,034
  • 10
  • 40
  • 66
  • I'm not sure I understand the issue. What you have looks like it should work. Can you perhaps provide more example data and the method calls you'd like to make? – jdobry Nov 09 '16 at 21:54
  • interesting, thanks @jdobry I think it may be something to do with the fact that in my example I am using an email as a key. See updated question. I also pasted the error – filype Nov 10 '16 at 00:00
  • The issue seems to be including this in the search `user%40example,com` – filype Nov 10 '16 at 03:19
  • @jdobry in other words, how could I get the array stored under `user%40example,com`? In firebase this would be done by `firebase.child('/logs/by_date/2016-11-02/user%40example,com')` - What would both the `defineMapper` and `find` look like? – filype Nov 11 '16 at 01:32

0 Answers0