Closed ezequieltejada closed 3 years ago
If this breaking change brings more stability to the project, we should allow a Filter[] as unique parameter type available. Keep in mind that this logic is used both in Onfirework.listDocs and in Onfirework.deleteDocs
The "operation" property should be taken from firebase.firestore.whereFilterOp
It would also be good, that the fieldPath was suggested based on the instance passed to the Onfirework class
I am working on this issue and I have seen that for it to work correctly, the input data type shouldn´t be a Filter[]
instance but a typeof WhereFilter []
where WhereFilter is a tuple of type [FieldPath, WhereFilterOp, any]
e.g:
import {FieldPath, WhereFilterOp} from '@google-cloud/firestore';
let WhereFilter: [FieldPath, WhereFilterOp, any]
listDocs(filter: typeof WhereFilter[]): Promise<T[]> {
filter.forEach((data: typeof WhereFilter) => (call = <any>call.where(...data)));
}
One of the solutions can be convert Interface <T>
to type Model
and pass results as definition of first element in filter tuple.
[Model, WhereFilterOp, any]
Similar as WhereFilterOp
works
Is fix on #12
Working on #1 it came to my mind the issue with typing the query.
How should we type the querys?
I suggest something like this:
But in index.ts:141 (for example) it makes a check if it is a filter or array of filters, Would it be simpler if we provided Filter[] as a type for the parameter in Onfirework.listDocs method's parameter? but it's going to be a breaking change depending how it was implemented.