I'm pretty new with Angular2, RethinkDB and Horizon API and I'm building a small webapp. In this app I'm trying to delete all objects in a specific table, and therefore I use the fetch() and removeAll() functions from Horizon API. The problem is the following error:
removeAll takes an array as an argument
The Horizon API's documentation is describing that the fetch() method returns an array, and I'm using this array to removeAll() data. Source: https://horizon.io/api/collection/#fetch
this.table.removeAll(this.table.fetch().subscribe(
result => console.log('Result:', result),
err => console.error(err),
() => console.log('Results fetched')
));
When I log the result of this fetch, it's displaying an array of Objects.
Result: [Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object]
I've tried declaring an array earlier and many other things but nothing seems to work. Any idea's?
You're very close but you're calling removeAll the wrong way. An example would be this:
ClearTable(): void {
this.table.fetch().subscribe(
(returnObjects: Object[]) => {
this.table.removeAll(returnObjects);
}
);
}
You can only manipulate the objects when you subscribe to them. Pass them to an array and now you've got the right objects to pass to the removeAll function