Meteor: different collections, different databases

My site will have two types of users: clients and administrators. They all need bills. And for accounts, the built-in meteorite accounting system uses a collection users. Are there ways to separate these two types of users into separate collections (for example, customersand admins), and not call them all in one separate collection? I could also have these types of users in separate databases (on different servers): one database for customers, and another for admins. So, how do you tell Meteor which database to use for which collection?

This is a type of e-commerce. Can someone tell me why one collection would be better for both clients and administrators? What are the advantages and disadvantages of using one collection instead of two when creating an online store?

+1
source share
2 answers

Why not split your meteorite into 2 instances, one for your client and one for your administration interface. Personally, I would use roles, but there is nothing wrong if you prefer:

Your meteor administrator admin js code

OtherMeteor = Meteor.connect("http://other_meteor_url")

//get user with username "admin"/connect to a custom method
OtherMeteor.call("getuser",{username:admin}, function(err,result) {
    console.log("result")
})

OR you can directly connect to the collection on another instance of the meteor

remote_meteor = Meteor.connect("http://other_meteor_url");
users2 = new Meteor.Collection("users", {manager: remote_meteor})

//wait for the subscription to finish first then use:
console.log(users2.find().fetch())
users2.up

Code in another meteor that performs custom functions:

Js server:

Meteor.methods({
    'getuser':function(query) {
        return Meteor.users.find(query).fetch();
    },
    'updateuser':function(query,modifier) {
        return Meteor.users.update(query,modifier);
    }
})
0
source

All Articles