nexabase-console 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +15 -15
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -22,33 +22,33 @@ export interface QueryConstraint {
|
|
|
22
22
|
directionStr?: 'asc' | 'desc';
|
|
23
23
|
limitValue?: number;
|
|
24
24
|
}
|
|
25
|
-
export interface DocumentReference {
|
|
25
|
+
export interface DocumentReference<T = any> {
|
|
26
26
|
type: 'document';
|
|
27
27
|
path: string;
|
|
28
28
|
db: NexaApp;
|
|
29
29
|
}
|
|
30
|
-
export interface CollectionReference {
|
|
30
|
+
export interface CollectionReference<T = any> {
|
|
31
31
|
type: 'collection';
|
|
32
32
|
path: string;
|
|
33
33
|
db: NexaApp;
|
|
34
34
|
}
|
|
35
|
-
export interface Query {
|
|
35
|
+
export interface Query<T = any> {
|
|
36
36
|
type: 'query' | 'collection';
|
|
37
37
|
path: string;
|
|
38
38
|
db: NexaApp;
|
|
39
39
|
constraints?: QueryConstraint[];
|
|
40
40
|
}
|
|
41
|
-
export interface DocumentSnapshot {
|
|
41
|
+
export interface DocumentSnapshot<T = any> {
|
|
42
42
|
exists: () => boolean;
|
|
43
|
-
data: () =>
|
|
43
|
+
data: () => T | null;
|
|
44
44
|
}
|
|
45
|
-
export interface QueryDocumentSnapshot {
|
|
45
|
+
export interface QueryDocumentSnapshot<T = any> {
|
|
46
46
|
id: string;
|
|
47
|
-
data: () =>
|
|
47
|
+
data: () => T;
|
|
48
48
|
}
|
|
49
|
-
export interface QuerySnapshot {
|
|
50
|
-
docs: QueryDocumentSnapshot[];
|
|
51
|
-
forEach: (callback: (doc: QueryDocumentSnapshot) => void) => void;
|
|
49
|
+
export interface QuerySnapshot<T = any> {
|
|
50
|
+
docs: QueryDocumentSnapshot<T>[];
|
|
51
|
+
forEach: (callback: (doc: QueryDocumentSnapshot<T>) => void) => void;
|
|
52
52
|
empty: boolean;
|
|
53
53
|
size: number;
|
|
54
54
|
docChanges?: () => any[];
|
|
@@ -124,14 +124,14 @@ export declare class NexaApp {
|
|
|
124
124
|
}
|
|
125
125
|
export declare const initializeApp: (config: NexaConfig) => NexaApp;
|
|
126
126
|
export declare const getFirestore: (app: NexaApp) => NexaApp;
|
|
127
|
-
export declare const collection: (db: NexaApp, collectionPath: string) => CollectionReference
|
|
128
|
-
export declare const doc: (dbOrCollection: NexaApp | CollectionReference
|
|
129
|
-
export declare const query: (queryObject: Query | CollectionReference
|
|
127
|
+
export declare const collection: <T = any>(db: NexaApp, collectionPath: string) => CollectionReference<T>;
|
|
128
|
+
export declare const doc: <T = any>(dbOrCollection: NexaApp | CollectionReference<any>, ...pathSegments: string[]) => DocumentReference<T>;
|
|
129
|
+
export declare const query: <T = any>(queryObject: Query<T> | CollectionReference<T>, ...queryConstraints: QueryConstraint[]) => Query<T>;
|
|
130
130
|
export declare const where: (fieldPath: string, opStr: "==" | ">" | "<" | ">=" | "<=" | "!=", value: any) => QueryConstraint;
|
|
131
131
|
export declare const orderBy: (fieldPath: string, directionStr?: "asc" | "desc") => QueryConstraint;
|
|
132
132
|
export declare const limit: (limitValue: number) => QueryConstraint;
|
|
133
|
-
export declare const getDocs: (queryOrCollection: Query | CollectionReference) => Promise<QuerySnapshot
|
|
134
|
-
export declare const getDoc: (docRef: DocumentReference) => Promise<DocumentSnapshot
|
|
133
|
+
export declare const getDocs: <T = any>(queryOrCollection: Query<T> | CollectionReference<T>) => Promise<QuerySnapshot<T>>;
|
|
134
|
+
export declare const getDoc: <T = any>(docRef: DocumentReference<T>) => Promise<DocumentSnapshot<T>>;
|
|
135
135
|
export declare const setDoc: (docRef: DocumentReference, data: any) => Promise<any>;
|
|
136
136
|
export declare const updateDoc: (docRef: DocumentReference, data: any) => Promise<any>;
|
|
137
137
|
export declare const deleteDoc: (docRef: DocumentReference) => Promise<any>;
|
package/dist/index.js
CHANGED
|
@@ -476,7 +476,7 @@ const getDoc = async (docRef) => {
|
|
|
476
476
|
throw err;
|
|
477
477
|
}
|
|
478
478
|
const data = db._firestoreCache[docRef.path];
|
|
479
|
-
return { exists: () => !!data, data: () => data || null };
|
|
479
|
+
return { exists: () => !!data, data: () => (data || null) };
|
|
480
480
|
}
|
|
481
481
|
};
|
|
482
482
|
exports.getDoc = getDoc;
|
package/package.json
CHANGED