-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathinterfaces.ts
47 lines (42 loc) · 1.34 KB
/
interfaces.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { Subscriber } from 'rxjs/Subscriber';
import * as firebase from 'firebase/app';
export interface DocumentChangeAction {
type: firebase.firestore.DocumentChangeType;
payload: firebase.firestore.DocumentChange;
}
export interface Action<T> {
type: string;
payload: T;
};
export interface Reference<T> {
onSnapshot: (sub: Subscriber<any>) => any;
}
// A convience type for making a query.
// Example: const query = (ref) => ref.where('name', == 'david');
export type QueryFn = (ref: firebase.firestore.CollectionReference) => firebase.firestore.Query;
/**
* A structure that provides an association between a reference
* and a query on that reference. Note: Performing operations
* on the reference can lead to confusing results with complicated
* queries.
*
* Example:
*
* const query = ref.where('type', '==', 'Book').
* .where('price', '>' 18.00)
* .where('price', '<' 100.00)
* .where('category', '==', 'Fiction')
* .where('publisher', '==', 'BigPublisher')
*
* // This addition would not be a result of the query above
* ref.add({
* type: 'Magazine',
* price: 4.99,
* category: 'Sports',
* publisher: 'SportsPublisher'
* });
*/
export interface AssociatedReference {
ref: firebase.firestore.CollectionReference;
query: firebase.firestore.Query;
}