Firestore - adding object with an array

Viewed 1979

killing myself with this thing in here all day, I'm having two classes Department and Articals :

export class Department {
articals?: Artical[]=[];
moms?: number;
id?: string;
constructor() {
}
}

and:

export class Artical {

moms?: number;
price: number;
name?: string;

constructor() {
}
}

like You can see departments contains an Array of 'Articals' so I am building new Department with new articals(and their properties) and trying to add it to fireStore with:

this.departmetsCollection.doc(departmentId).set(Object.assign({}, 
myDepartment));

but getting Error : "Function DocumentReference.set() called with invalid data. Unsupported field value: a custom Artical object"

P.s tryed add only array of articals to the path of department as

doc(departmentId).set({'articals':myArticals});

and with 'update' instead of 'set' but no help either:S what is teh correct of adding that kind of object to firestore?

1 Answers
Related