-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(filtering): Bump FirestoreStorage dependency and enable Firestore Filter capabilities #40
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import { BaseModel, ModelQuery } from './types'; | ||
import { getPath } from 'ts-object-path'; | ||
import { Filter } from '@google-cloud/firestore'; | ||
|
||
export type WhereProp<T extends BaseModel> = string | ((t: T) => unknown); | ||
|
||
export abstract class BaseQuery<T extends BaseModel, Op extends string, R> { | ||
protected abstract applyWhere(key: string, operator: Op, value: any): this; | ||
protected abstract applyWhere(key: string | Filter, operator: Op, value: any): this; | ||
protected abstract applyWhere(filter: Filter): this; | ||
abstract execute(): R; | ||
|
||
where(prop: WhereProp<T>, op: Op, value: any) { | ||
return this.applyWhere(this.getWhereProp(prop), op, value); | ||
where(propOrFilter: WhereProp<T> | Filter, op?: Op, value?: any) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just copying it as is into the storage package? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it works, if you override the |
||
if (propOrFilter instanceof Filter) { | ||
return this.applyWhere(propOrFilter); | ||
} | ||
return this.applyWhere(this.getWhereProp(propOrFilter), op!, value); | ||
} | ||
|
||
whereAll<K extends ModelQuery<T>>(attributes: K | null) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That dependency would not work in the browser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn - Forgot about web. A generic "Filter" class or type can be made instead of relying on the type from this import.