I am currently struggling with using Firestore to store data on a webpage. I am attempting to store an array of custom objects, but for some reason Firestore is not allowing me to do so. I have attempted to pass it as an object of objects, but it keeps getting rejected. Can anyone guide me on how to accomplish this task? Below is the code snippet I am working with:
function Book(title, author, pages, read) {
this.title = title;
this.author = author;
this.pages = pages;
this.read = read;
}
let myLibrary = [
(new Book("1984", "George Orwell", 123, "Read")),
(new Book("Lord of the Rings", "JRR Tolkien", 300, "Read")),
(new Book("Neuromante", "William Gibson", 200, "Read"))
];
var firestore = firebase.firestore();
const docRef = firestore.collection('books');
docRef.doc('myLibrary').set(myLibrary);