Is it feasible to set a future date and time in a firestore document and trigger a function when that deadline is reached? Let's say, today I create a document and specify a date for the published
field to be set to false
fifteen days later. Can this be done?
This is how I am creating a document in firestore:
component.ts
import { Component, OnInit } from '@angular/core';
import { FirebaseService } from '../../../services/firebase.service';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
form: FormGroup;
constructor( fb: FormBuilder, private fs: FirebaseService ) {
this.form = fb.group ({
creationDate: [ firebase.firestore.FieldValue.serverTimestamp() ],
published: [ true ],
})
}
addNotice() {
this.fs.addNotice(this.form.value);
}
firebase.service.ts
constructor( private afs: AngularFirestore ) {}
addNotice(notice){
this.afs.collection('notices').add(notice);
}
The result obtained is shown here: https://i.stack.imgur.com/AmTfg.png