Previously, I utilized Firebase as my database service. When I received the Observable from Firebase and subscribed to it:
const projectsFromDatabase = this.afDB.list(this.basePath, {
query: query
});
console.log(projectsFromDatabase.subscribe(res => {console.log(res)}); // just for testing
return projectsFromDatabase;
I obtained the following data structure:
[
{
0:
{data: 0, value : 0, $key: ABC}
},
{
1:
{data:1, value:1 , $key: DEF}
}
]
Now, I am transitioning from Firebase to MongoDB. I have an observable retrieved from an API:
const projectsFromDatabase = this
.http
.get(url)
.map(res => {
return res;
});
console.log(projectsFromDatabase.subscribe(res => {console.log(res)}); // just for testing
return projectsFromDatabase;
and the data structure is quite different:
[
{
0:
{
ABC:{data: 0, value : 0},
DEF:{data: 1, value : 1}
}
}
]
Is there a way to transform the second observable into something similar to the first one, so that I can subscribe to it later and achieve the same result? I've attempted to subscribe, modify, and push it to a new observable, but the length of my observable always remains at 0. Any other suggestions?