我正在将Google的Firestore用作应用程序的后端。我正在设置ngrx和ngData,我需要重写标准函数。当我对getAll执行此操作时,一切正常。尽管我还没有调用getById方法,但它似乎可以正常工作。
问题是,当我尝试覆盖更新,删除或创建时,它给我一个错误,即“ XDataService”类型的参数不能分配给“ EntityCollectionDataService”类型的参数。
我使用的语法与getAll相同。我不确定我在这里要打破什么。
@Injectable() 导出类makDesignDataService扩展了DefaultDataService {
constructor(http : HttpClient,
httpUrlGenerator : HttpUrlGenerator,
public afs : AngularFirestore,
private store : Store<AuthState>,
private MarketplaceService : MarketplaceService ) {
super('makDesign', http, httpUrlGenerator);
}
// Read - works fine
getAll(): Observable<makDesign[]> {
return <Observable<makDesign[]>> this.afs.collection('designs', ref => ref
.where('status', '==', 1 )
.where('deleted', '==', false))
.valueChanges()
}
// Read
getById( designId : string ):Observable<makDesign>
{
return <Observable<makDesign>> this.afs.collection('designs').doc( designId )
.valueChanges()
}
// Update - doesn't work
update( updateItem : makDesign )
{
this.afs.collection('designs').doc( updateItem.id ).update( updateItem );
}
// Delete - doesn't work
delete( designId : string )
{
this.afs.collection('designs').doc( designId ).update( { 'deleted' : true } );
}
}