I have this cf:
const paymentsCf = crossfilter([
{id: 1, quantity: 2, total: 190, tip: 100, type: "tab"},
{id: 2, quantity: 2, total: 190, tip: 100, type: "tab"},
{id: 3, quantity: 1, total: 300, tip: 200, type: "visa"}
]);
and I'm creating a dimension by ID and filtering it like this:
const dimension = paymentsCf.dimension(({ id }) => id);
dimension.filter(2);
If I do console.log(paymentsCf.groupAll().value())
fair enough I see 1
.
But how can I access the whole filtered object to get the quantity, total, tip and type?
I know I can do feedbackCf.all()
but that shows me all the 3 objects. Not only the filtered one.
Thanks!
You just need to add the top()
method to expose the result:
const dimension = paymentsCf.dimension(({ id }) => id);
const res = dimension.filter(2);
res.top(1);
output:
[ { id: 2, quantity: 2, total: 190, tip: 100, type: 'tab' } ]