Node.js &引用;使用无效数据调用函数Query.where()。不支持的字段值:未定义";与firebase的角度误差

Node.js &引用;使用无效数据调用函数Query.where()。不支持的字段值:未定义";与firebase的角度误差,node.js,angular,firebase,npm,google-cloud-firestore,Node.js,Angular,Firebase,Npm,Google Cloud Firestore,我正在使用angular创建一个使用firebase的预订web应用程序。我试图通过firebase数据进行查询并对其进行过滤,以避免在同一时间段记录重复的预订,但我不断收到错误函数query.where(),该函数使用无效数据调用。不支持的字段值:未定义。我是angular和firebase的新手,这也是我的第一个项目。我真的需要一些帮助 checkTimeSlot(){ this.formData.date_time = this.formData.bookDate + "_&qu

我正在使用angular创建一个使用firebase的预订web应用程序。我试图通过firebase数据进行查询并对其进行过滤,以避免在同一时间段记录重复的预订,但我不断收到错误
函数query.where(),该函数使用无效数据调用。不支持的字段值:未定义
。我是angular和firebase的新手,这也是我的第一个项目。我真的需要一些帮助

checkTimeSlot(){
this.formData.date_time = this.formData.bookDate + "_"+ this.formData.timeSlot;

const queryTimeRefUFC =  this.afs
.collection("ufc", ref => ref.where("date_time", "==", this.formData.date_time))
.get();


if (queryTimeRefUFC == null){
  console.log("true");
  return true;      
}
else{
  console.log("false");
  return false;
}}
这就是我在component.ts中创建查询搜索的方法。当select输入中的值更改时,将调用此方法

submitBookingUFC() {
this.formData.fullName = this.user.name;
this.formData.userID = this.user.id;
this.formData.date_time = this.formData.bookDate + "_"+ this.formData.timeSlot;

if (this.checkTimeSlot() == true){
  alert("The Time Slot you have selected has already been taken. Please select another.");    
}
else if (this.checkTimeSlot() == false){
  console.log(this.formData.date_time);
  this.crudApi.SaveBookingUFC(this.formData);
  alert("Record Saved Successfully");    
  this.ResetFormUFC();  // Reset form when clicked on reset button
} }
这是用户单击submit按钮时调用的方法

        <div>
            <input 
            type="date" 
            class="in-bdate"
            id="dateUFC"
            name="dateUFC"
            [min]="today"
            max="{{bookMax}}"
            value="{{formData.bookDate}}"
            [(ngModel)]="formData.bookDate"
            #dateUFC="ngModel"
            required>
        </div>
        <div>
            <div style="color:red" 
                *ngIf="dateUFC.errors && (dateUFC.dirty || dateUFC.touched)">    
                <p *ngIf="dateUFC.errors.required">
                    <sup>*</sup>Booking Date is required
                </p>
            </div>
        </div>         

        <div *ngIf="!dateUFC.errors && (dateUFC.dirty || dateUFC.touched)">
            <div>
                <label for="timesUFC">Time Slot</label>
            </div>
            <div>
                <select 
                    name="timesUFC" 
                    class="in-tslot"
                    value="{{formData.timeSlot}}"
                    (change)="checkTimeSlot()"
                    [(ngModel)]="formData.timeSlot"
                    #timeSlotUFC="ngModel"                        
                    required>
                    <option  *ngFor="let time of timesUFC" >{{time.name}}</option>
                </select>
            </div>
            <div>
                <div style="color:red" 
                    *ngIf="(timeSlotUFC.dirty || timeSlotUFC.touched)">    
                    <p *ngIf="timeSlotUFC.errors && timeSlotUFC.errors.required">
                        <sup>*</sup>Time Slot is required
                    </p>
                    <p [ngModel]="timeError" name="error" ngDefaultControl>{{ timeError }}</p>
                </div>
            </div>
        </div>            
这是UfcData类中的数据

我需要的是从表单中获取用户的输入,该表单从ngModel获取到UfcData类,并确保cloud firestore中没有任何日期和时间完全相同的文档

*稍微调整代码后,不会显示上述错误。但是,
checkTimeSlot()
方法中的if条件始终返回true,无论选择的选项是什么。


提前感谢。

请添加更多上下文并向我们展示更多代码,好吗?还有,你用过!this.afs.collection(集合中的否定)。请参考此链接了解我添加了更多上下文的集合。对不起,这是我第一次在这里发帖。
export class UfcData {
docID!: string;
userID!: string;
fullName!: string;
contactNo!: string;
timeSlot!: string;
bookDate!: string;
date_time!: string;}