first commit
This commit is contained in:
12
src/app/_api/user/user.service.spec.ts
Normal file
12
src/app/_api/user/user.service.spec.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserService } from './user.service';
|
||||
|
||||
describe('UserService', () => {
|
||||
beforeEach(() => TestBed.configureTestingModule({}));
|
||||
|
||||
it('should be created', () => {
|
||||
const service: UserService = TestBed.get(UserService);
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
27
src/app/_api/user/user.service.ts
Normal file
27
src/app/_api/user/user.service.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AngularFirestore } from '@angular/fire/compat/firestore';
|
||||
import firebase from 'firebase/compat/app';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class UserService {
|
||||
ref = firebase.firestore().collection('users');
|
||||
|
||||
constructor(private firestore: AngularFirestore) {
|
||||
}
|
||||
|
||||
getUsers() {
|
||||
return this.firestore.collection('users').snapshotChanges();
|
||||
}
|
||||
|
||||
getCurrentUser(userId): Observable<any> {
|
||||
return this.firestore.collection('users', ref => ref.where('uid', '==', userId)).snapshotChanges();
|
||||
}
|
||||
|
||||
createUser(user) {
|
||||
return this.ref.add(user);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user