0

My Actual Query, How can I make a select query in a SQL database?

I need doo something like this SELECT * FROM IMOBI WHERE GOAL == 'Venda' AND TYPES == 'Residencial'

My Database:

export function getFilterTypeResidence() {
    if (Firebase === null) return () => new Promise(resolve => resolve());
    return dispatch => new Promise(resolve => FirebaseRef.child('imobi')
        .orderByChild('types').equalTo('Residencial').once('value', (snapshot) => {
        const realestate = snapshot.val() || {};
        const filter = Object.values(realestate);    
        return resolve(dispatch({
          type: 'GET_TYPE',
          data: filter
        }));
    })).catch(e => console.log(e));
}
M Reza
  • 18,350
  • 14
  • 66
  • 71
  • The real-time database doesn't support this kind of query. It's only queryable against one point. The best thing to try is to get the data as small as you can with one query, then loop through the results and further reduce the results with Javascript. – sketchthat Apr 23 '18 at 01:25
  • What I wanted to do to solve this problem would be a single select with the types and the goal together? – Rafael Caldeira Apr 23 '18 at 01:36
  • It's not possible in the Real Time Database. – sketchthat Apr 23 '18 at 01:36
  • Ok, I understand now, thanks – Rafael Caldeira Apr 23 '18 at 01:39
  • Firebase Database queries can only order/filter on a single property. In many cases it is possible to combine the values you want to filter on into a single (synthetic) property. For example in your case that could be `"GOAL_TYPES": "Venda_Residencial"`. For more examples of this and other approaches, see my answer here: http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Apr 23 '18 at 02:07

0 Answers0