arunoda / meteor-smart-collections

Meteor Collections Re-Imagined
MIT License
147 stars 13 forks source link

capped collections don't stay capped through SmartCollections #38

Closed jamesmanning closed 10 years ago

jamesmanning commented 11 years ago

I created a capped collection with count limit of 100:

db.createCollection('last100', {capped : true, size: 1024*1024, max: 100 })

The MongoDB is correctly keeping the total count at 100 as items are added, but the client side is not doing so:

image

Using observeChanges, it appears that only "added" happens - not sure if that means the opLog doesn't record 'removes' for capped collections (and they're implicit) or if they're recorded in some different format than a normal remove or what.

This was the js I used (in a top-level .js, running on both client and server)

Last100 = new Meteor.SmartCollection("last100"); 
Query = Last100.find();
var count = 0;
Query.observeChanges({
    added: function (id, user) {
        count++;
        console.log("ADDED:", count, Query.count());
    },
    removed: function () {
        count--;
        console.log("REMOVED:", count, Query.count());
    }
});
arunoda commented 10 years ago

SmartCollections does not see different between a capped collection and a normal collection. You need add some limit condition.