Hi I have an 2 apps one for admins and one for clients connecting to the same database.
My question is how to share collections between two apps connecting to the same database instead of duplicating them?
thank you
Hi I have an 2 apps one for admins and one for clients connecting to the same database.
My question is how to share collections between two apps connecting to the same database instead of duplicating them?
thank you
Just declare your collections with the same name. e.g.
app 1:
C = new Mongo.Collection(“COLLECTION_NAME”);
app 2:
C = new Mongo.Collection(“COLLECTION_NAME”);
“C” can be anything, but “COLLECTION_NAME” has to be the same.
Thanks @hiukim I’m fully aware of that but I need to the collections to be shard with the 2 apps which means defines them once and used in both apps ist accomplished with packages or what? If is can I define local package?
Yes - that’s the way to do this.
Local packages are easy in Meteor. If the package(s) is only ever going to be for this app, then create a packages/
folder off your application root and within that you can put your individual package directories. Packages may be created using meteor create creator:package-name --package
from the packages/
folder (owner
would usually be your Meteor Developer name and package-name
is whatever you want).
If you want to re-use packages, create a folder out of your application structure and create your packages in there. Then set the PACKAGE_DIRS
environment variable to the path to that folder.
In either case, you can then meteor add creator:package-name
in the usual way.
Check the Meteor Guide for more info.