简体   繁体   中英

Multi user connection in massive.js

I wish to have connected more than 1 users at the same time, as follows:

const massive = require('massive');

massive({
    host: 'localhost',
    port: 5432,
    database: 'appdb',
    user: 'user_1',
    password: 'pwd_1',
    ssl: false,
    poolSize: 10
}).then(instance_1 => {...});

massive({
    host: 'localhost',
    port: 5432,
    database: 'appdb',
    user: 'user_2',
    password: 'pwd_2',
    ssl: false,
    poolSize: 10
}).then(instance_2 => {...});

user_1 and user_2 obviously have different privileges.

So, my question is: in which way the two instances 1 and 2 are related? In the beginning, I suspect they are identical. Later, do they get synchronized ? Do I have to run db.reload() ?

Tia

The short answer is that you don't have anything to worry about unless and until you make schema changes. If you do modify the schema at runtime you will need to call db.reload() from each instance to ensure that they're current. However, modifying the schema at runtime is an uncommon use case to say the least.

The two instances are completely independent and are never automatically synchronized. The database objects (tables, views, etc) that both users have access to will be identical until a change is made and one is reloaded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM