Can anyone know how to use the new functions of rawCollection and rawConnection that are newly released in 1.0.4 version of Meteor? I have searched from both official docs and even Google, but there is no dos or examples exist yet…
I am building a system to present a large mount of data in real-time with complex filter form enabled. Now I need provide distinct values from some columns of the data source for drop down list in the filter form. What i am doing now is query data from Mongo DB like:
When using rawCollection you will need to wrap the calls in a ‘meteor fiber’.
Here is part of a method I use to pass an array of documents to insert.
Most of the heavy lifting is done by Meteor.wrapAsync. You are not using mini mongo and must make the node\async code play nice with Meteor. I’ve simplified the code a bit here. You probably want to wrap the call in a try/catch to pick up an error. See the wrapAsync docs.
setWeeklyResults: function(theData) {
// blow away the old documents
WeeklyResults.remove({
week: theData[0].week
});
var collect = WeeklyResults.rawCollection();
var mongoInsertSync = Meteor.wrapAsync(collect.insert, collect);
var result = mongoInsertSync(theData);