Home > database >  flutter - firebase - query check if two fields are not empty
flutter - firebase - query check if two fields are not empty

Time:11-17

In my app, I must check if two fields are not empty.

it seems that it is not possible. So, I have done the code below.

I am getting this error: Unhandled Exception: 'package:cloud_firestore/src/query.dart': Failed assertion: line 313 pos 7: 'field is String || field is FieldPath || field == FieldPath.documentId': Supported [field] types are [String] and [FieldPath].

I must make sure that I have not fields empty because it will generate an error because I am parsing the text. Thank you.

myQueryResult.where('start_Date', isNotEqualTo: '');

myQueryResult = myQueryResult.where('due_Date'.length, isEqualTo : 16);

CodePudding user response:

From the documentation on Firestore query limitations:

In a compound query, range (<, <=, >, >=) and not equals (!=, not-in) comparisons must all filter on the same field.

So you can't check non-equality on two different fields. You'll either have to perform one of the conditions in the query, and the other in your application code (which reads more data than needed), or you will have to introduce an additional field in your document that combines the two things you want to check for in a single value that you can then query on (which stores additional data to prevent reading more than needed).

  • Related