How can I add a future date and time to a firestore document and add a function when that time expires? For example today I create a document and record that time and then I want to register that fifteen days later the publicado
field will be false
. It's possible?
I am creating a document in firestore in the following way:
component.ts
import { Component, OnInit } from '@angular/core';
import { FirebaseService } from '../../../services/firebase.service';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
forma: FormGroup;
constructor( fb: FormBuilder, private fs: FirebaseService ) {
this.forma = fb.group ({
fechaCreacion: [ firebase.firestore.FieldValue.serverTimestamp() ],
publicado: [ true ],
})
}
agregarAviso() {
this.fs.addAviso(this.forma.value);
}
firebase.service.ts
constructor( private afs: AngularFirestore ) {}
addAviso(aviso){
this.afs.collection('avisos').add(aviso);
}