Skip to content

Instantly share code, notes, and snippets.

@uno-de-piera uno-de-piera/afire.service.ts Secret
Created May 26, 2018

What would you like to do?
import { Injectable } from '@angular/core';
import {AngularFirestore, AngularFirestoreCollection} from 'angularfire2/firestore';
import * as faker from 'faker';
type todosCollection = AngularFirestoreCollection<any[]>;
providedIn: 'root'
export class AfireService {
private afs: AngularFirestore,
) {}
all (): todosCollection {
return this.afs.collection('todos');
add (todoText: string): Promise<any> {
const id = faker.random.alphaNumeric(16);
const data = {
todo: todoText
return this.afs.doc(`/todos/${id}`).set(data);
remove (id: string): Promise<any> {
return this.all().doc(id).delete();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.