I manually created this Firestore document using the console, setting enabled as a boolean type. Now, I am expanding on the functionality to update it in Angular with the following code snippet.
activateMenuItem(venueId: string, menuId: string, menuItemId, enabled: boolean) {
const update = {
'enabled': false
};
update.enabled = enabled;
const db = this.firestore.firestore;
from(db.collection('venues')
.doc(venueId)
.collection('menus')
.doc(menuId)
.collection('items')
.doc(menuItemId)
.update(update))
.subscribe(value => {
console.log("On next");
}, (error) => {
console.log("on error" + error);
});
}
Everything is functioning correctly, however, when I assign the boolean value to the field enabled, the field type changes to a string afterward.
Before
https://i.sstatic.net/YMIzw.png
After
https://i.sstatic.net/ZsSSp.png
Here is additional code showing how it is being called:
onChange(enabled) {
console.log("Changing " + enabled);
this.service.activateMenuItem(this.venueId, this.menuId, this.menuItemId, enabled);
}