Я загружаю в базу данных так:
Мой объект, который я хочу загрузить:
export class Data {
$key: string;
name: string;
address: string;
address2: string;
pscode: string;
ccode: string;
name2: string;
trucks: Trucks;
trailers: Trailers;
email: string;
phone: string;
city: string;
country: string;
}
**Upload service :**
getItem: Observable<Data[]>;
key: string;
busines = {} as Data;
createItemAuth() {
this.afAuth.authState.subscribe(auth => {
this.afDatabase.list(`users/${this.auth.userId}/company`).push(this.busines)
});
}
//this not works :
getUploads() {
this.getItem = this.afDatabase.list(`profile/${this.auth.userId}/company/`).snapshotChanges().map((actions) => {
return actions.map((a) => {
const data = a.payload.val();
const $key = a.payload.key;
const $ref = a.payload.ref;
return { $key, ...data, $ref };
});
});
return this.getItem;
}
на getUploads()
this.getItem
Я получаю:
Type '{$ ref: Reference;$ key: string;} [] 'нельзя назначить типу' Data [] '.Тип '{$ ref: Reference;$ key: string;} 'нельзя назначить типу' Данные '.Свойство 'name' отсутствует в типе '{$ ref: Reference;$ key: string;} '.
Что с этим не так?