Created
March 22, 2020 20:27
-
-
Save trblackw/7f6bf09d5ec1e1c451ad5f511add6271 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { FirebaseModel } from "../firebaseTypes" | |
import { User } from "./userTypes" | |
export default class UserModel extends FirebaseModel { | |
public async getCurrentUser(userId: string): Promise<User> { | |
const currentUser = await this.store | |
.collection(UserModel.userCollection) | |
.doc(userId) | |
.get() | |
return { ...currentUser.data(), id: currentUser.id } as User | |
} | |
public async getAllUsers(): Promise<User[]> { | |
const userCollection = await this.store.collection(UserModel.userCollection).get() | |
return userCollection.map(user => ({ | |
...user.data(), | |
id: user.id, | |
})) as User[] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment