Skip to content

Instantly share code, notes, and snippets.

@bariscanyilmaz
Created April 24, 2019 18:48
Show Gist options
  • Save bariscanyilmaz/4e5869bb5da30868d5492e9ea1e598f0 to your computer and use it in GitHub Desktop.
Save bariscanyilmaz/4e5869bb5da30868d5492e9ea1e598f0 to your computer and use it in GitHub Desktop.
import { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/firestore';
import { Injectable } from '@angular/core';
import { Book } from "../models/book.model";
import { Category } from '../models/category.model';
@Injectable({
providedIn: 'root'
})
export class BookService {
constructor(private fireStore: AngularFirestore) {
}
addBook(book: Book) {
return this.fireStore.collection('Books').add({...book});
}
getBook(category: string) {
return this.fireStore.collection('Books',ref=>ref.where('Categories','array-contains',category)).valueChanges();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment