Ad
How To Update Whole Collection? Firebase Database Migration
I've made some updates in Article model and it's affects to all elements in the collection so I need to update whole collection.
I don't know how should make it in the right way. In ASP.NET it calls "Database Migration". When you can remove old fields and add new to all items in one click.
Here is my model.
Old model:
// article.ts
export class Article {
id?: string;
title: string;
text: string;
views: number;
archived: boolean;
published: boolean;
}
Updated model:
// article.ts
export class Article {
id?: string;
title: string;
text: string;
views: number;
status: Status;
}
export enum Status {
Archived = 'archived',
Draft = 'draft',
Published = 'published'
}
How should I update all items inside collections?
Ad
Answer
Neither database available with Firebase (Realtime Database and Cloud Firestore) have the ability to bulk update fields or perform migrations. You have to read each of the items, then write back the fields each item should contain.
Ad
source: stackoverflow.com
Related Questions
- → Make a Laravel collection into angular array (octobercms)
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → Angularjs not working inside laravel form
- → Analysis of Flux implementations
- → how to write react component to construct HTML DOM
- → angular ng-repeat and images in a row
- → Conditional BG Color on AngularJS
- → Should I 'use strict' for every single javascript function I write?
- → getting the correct record in Angular with a json feed and passed data
- → "Undefined is not a function" at .toBe fucntion
- → angularjs data binding issue
- → Angular / JavaScript auto hydrate an instance
- → Convert generic text string in json object into valid url using Angular
Ad