IjzerenHein / firestorter

Use Google Firestore in React with zero effort, using MobX 🤘
http://firestorter.com
MIT License
378 stars 50 forks source link

Collection.query is not working #93

Closed gsouf closed 4 years ago

gsouf commented 4 years ago

Hello,

I have issues using the query option/method of the the collection.

It's not evaluated at all.

The example bellow won't take into account my "limit=3"

import { observer } from 'mobx-react';
@observer
export default class StockHistoryScreen extends React.Component {
  constructor(props) {
    super(props);
    this.collection = new Collection('mycollection', {
      query: ref => {
        ref.limit(3);
      }
    });
  }

  render() {
    const { navigate } = this.props.navigation;

    return (
      <View>
        {this.collection.docs.map(doc => {
          return <View>{doc.id}</View>;
        })}
      </View>
    );
IjzerenHein commented 4 years ago

Hi! There seems to be an error in your code.

query: ref => {
        ref.limit(3);
      }

should be:

query: ref => {
        return ref.limit(3);
      }

or

query: ref => ref.limit(3)
gsouf commented 4 years ago

@IjzerenHein thanks for your input but I confirm it does not work, the function passed in the param query is not called at all.

IjzerenHein commented 4 years ago

Hmm that is strange indeed. Are you getting any docs at all?

gsouf commented 4 years ago

I'm getting all docs in the collection, like if I didn't specify any query. As I said it's not evaluated at all. So the same occurs with where or orderBy. Missing something obvious?

IjzerenHein commented 4 years ago

That is so weird.. The query arg is a critical part of Firestorter, without it you couldn't do any kind of query's, so it's hard to believe it's broken. Can you perhaps share a small sample app on codesandbox/stackblitz that shows the problem?

gsouf commented 4 years ago

found the issue, was related to some tools out of the scope of firestorter sorry for the mess