I’d like to use Meteor’s datastore as a cache for resources that come from endpoints external to Meteor. I thought I could do it by creating a new class that extends Cursor and overrides the fetch()
, etc.
I (think) I’m aiming to have the fetch
method do something like check if a document exists in Mongo, iff not then query an endpoint specified in the original Meteor.Collection.find
call (f.e. collection.find({_id: 123, _endpoint: 'http://whatever/'})
), then if the data is found at the endpoint insert it into Mongo, then finally fetch returns the results.
So maybe I have to extend both Collection and Cursor? Any suggestions that might point me in the right direction?