My goal is to structure the Firebase database in the following way:
"thumbnails": {
"72": "http://url.to.72px.thumbnail",
"144": "http://url.to.144px.thumbnail"
}
However, I am struggling to correctly set the keys '72' and '144' as they are calculated values before being pushed to the db, representing the pixels of an image.
let pixel = this.calcPixels();
let obj = ?????
var updates = {};
updates['/guid/thumbnails/'] = obj;
let masterRef = this.db.database.ref();
masterRef.update(updates);
I attempted the following approach, but it doesn't work as intended:
let obj = { pixel : this.getUrl()}
Creating a class for sending data also presents an issue where the class members (pixelx, urlx) become the key on the server.
class PixelData{
pixelx:number;
urlx:string;
constructor(p:number,u:string){
this.pixelx = p;
this.urlx = u;
}
}
As a result, setting this obj produces the following output when pushed to the Firebase database under thumbnails:
"thumbnails": {
"pixelx": 72
"urlx": "http://url.to.72px.thumbnail",
}
Any suggestions or solutions would be greatly appreciated. Thank you.