I am very new to mongodb. I am basically trying to retrieve data from a collection and put to screen. Its an angular2-meteor app. I can insert and retrieve data inside the mongo shell. But when I try to loop through the value bookmarks i get the error:
Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
When i console log the returned data from the find() method, it returns the entire mongodb objects collection and the boomarks collection is deeply buried inside the object.
How can I get an array of all the objects inside the returned bookmarks variable returned using the .find() method?
My component is as below:
import { Component } from '@angular/core';
import template from './bookmarks.component.html';
import { Bookmarks } from '../../../../collections/bookmarks';
import { Mongo } from 'meteor/mongo';
@Component({
selector: 'bookmarks-list',
template
})
export class bookmarksListComponent {
bookmarks: Mongo.Cursor<Object>;
constructor() {
this.bookmarks=Bookmarks.find();
console.log(this.bookmarks);
}
}
here is the html template:
<tbody>
<tr *ngFor="let bookmark of bookmarks">
<td>{{bookmark.title}}</td>
<td>{{bookmark.url}}</td>
<td>{{bookmark.category}}</td>
<td><button class="btn btn-danger">Delete</button></td>
</tr>
</tbody>