inProgress-team / react-native-meteor

Meteor Reactivity for your React Native application :)
MIT License
693 stars 210 forks source link

[REQUEST] Be able to have local only collection #341

Open schlaegerz opened 5 years ago

schlaegerz commented 5 years ago

I have a case where I want to keep some data locally and it is much easier for various reasons if it is a mongo collection from Meteor, I do this on web with meteor so it should be easily possible to do it with this package.

On web when you create a new mongo collection new Mongo.Collection(null, {connection: null}) Either passing no name, or passing 'connection:null' will result in it being a local only collection.

Right now if you were to make this collection all the items get removed after a short time out due to trying to insert it in a server collection.

My suggested change is to check mark it as a local connection in the case where you don't pass a name, and then skip the ddp calls in the insert/update/remove functions.

Temporary workaround I found is I can call: myCollection._collection.upsert({_id: data._id}, {$set:data}) Which skips all the ddp logic.