Reputation: 145
I am a newbie to development and Meteor brought me in. I have the following scripts:
In the Lib Folder
Transactions = new Meteor.Collection('transaction');
Server
Meteor.publish('trans',function(){
return Transactions.find({});
});
Client
Meteor.subscribe('trans');
My Collection named Transactions contains the following objects
{
date: Date,
amount: Number,
userid: Meteor.userId()
}
I would like to return a list of all the different dates contained in the collection, without any duplicate.
Upvotes: 1
Views: 585
Reputation: 145
Template.view.helpers({
viewDate:function(){
var transactions = Transactions.find({userid:Meteor.userId()}).fetch();
return _.uniq(transactions, false, function(transaction) {return transaction.date});
}
});
This made my day... Thank You @chrishillonline
Upvotes: 3
Reputation: 25
return _.uniq(Transactions.find({}), function(transaction) {return JSON.stringify(transaction)});
Upvotes: 0