Hello !
I have a little problem to transform a collection and sorting the data from.
I have a basic test Collection
{
{_id:1,name:“a”},
{_id:2,name:“c”},
{_id:3,name:“b”},
}
/server and client side/
var test = new Mongo.Collection(“test”);
/server side/
Meteor.publish(“test”,function(){
return test.find({},{sort:{name:1});
})
/client side/
Meteor.susbcribe(‘test’);
I sort in asc order ‘a,c,b’ so the result is -> ‘a,b,c’
Ok for this.
But if i want to transform the collection doc like this ->
test = new Mongo.Collection(“test”, {
transform: function (doc) {
if (doc.name == “b”) {
doc.name = “z”;
}
return doc;
}
});
The result is -> 'a,z,c’
In fact, the doc ‘b’ has well been replace by ‘z’, but the sort option is not updated so…
I want to transform field name ‘b’ by ‘z’ to have this sort result : ‘a,c,z’
Than’s a lot for your help.
JP