【发布时间】:2019-11-20 09:07:32
【问题描述】:
我有一个这样的 Firebase 集合:
我正在尝试使用此代码获取具有日期范围条件的数据:
ticket-form.component.ts
onSubmmitDates(value: any) {
debugger;
this.ts.getSpecificTicket(value.dateFrom, value.dateTo).subscribe((data: any) =>{
console.log(data);
});
}
ticket.service.ts
private ticketList: AngularFireList<any>;
constructor(
private firestore: AngularFirestore,
private afDatabase: AngularFireDatabase,
) { }
getSpecificTicket(dateFrom: Date, dateTo: Date): any {
this.ticketList = this.afDatabase.list('tickets', ref =>
ref.orderByChild('issuedOn').startAt(dateFrom.toString()).endAt(dateTo.toString()));
return this.ticketList.snapshotChanges();
}
当我运行它时,我得到了这个错误:
错误错误:permission_denied at /tickets:客户端没有 访问所需数据的权限。 在 errorForServerCode (index.cjs.js:642) 在 onComplete (index.cjs.js:8944) 在 Object.onComplete (index.cjs.js:12467) 在 index.cjs.js:11611 在 PersistentConnection.push../node_modules/@firebase/database/dist/index.cjs.js.PersistentConnection.onDataMessage_ (index.cjs.js:11853) 在 Connection.push../node_modules/@firebase/database/dist/index.cjs.js.Connection.onDataMessage_ (index.cjs.js:11170) 在 Connection.push../node_modules/@firebase/database/dist/index.cjs.js.Connection.onPrimaryMessageReceived_ (index.cjs.js:11164) 在 WebSocketConnection.onMessage (index.cjs.js:11065) 在 WebSocketConnection.push../node_modules/@firebase/database/dist/index.cjs.js.WebSocketConnection.appendFrame_ (index.cjs.js:10657) 在 WebSocketConnection.push../node_modules/@firebase/database/dist/index.cjs.js.WebSocketConnection.handleIncomingFrame (index.cjs.js:10707)
这是我的规则:
我能做些什么来解决这个问题?
【问题讨论】:
-
您是否为您的项目正确设置了 Firebase?看看这个指南:github.com/angular/angularfire/blob/master/docs/…