#1 2014-10-03 15:16:20

ChinaPeng
Member
Registered: 2014-10-02
Posts: 15

How mORMot access mutl database?

hi AB
   I have many DB Instance On  SQL Server

   How to access these database use mORMot?

  Like this:

   UserA access ->  DB_0001 
   UserB access ->  DB_0002
   ...more

Offline

#2 2014-10-03 15:54:17

Sabbiolina
Member
Registered: 2014-05-20
Posts: 120

Re: How mORMot access mutl database?

HI,
each user must map a different root, which corresponds to a different db.

look at 'rtest':


  MongoClient := TMongoClient.Create('localhost',27017);
  DB := MongoClient.Database['testODM'];
  Model := TSQLModel.Create([TSQLORM,TSQLauthUser,TSQLauthGroup]); // <<-------------------- root

  MongoClient2 := TMongoClient.Create('localhost',27017);
  DB2 := MongoClient2.Database['testODM2'];
  Model2 := TSQLModel.Create([TSQLORM,TSQLauthUser,TSQLauthGroup],'rtest'); //<------------------------------------- rtest


  // create the main mORMot server
  aRestServer := TSQLRestServerDB.Create(Model,':memory:',false);
  aRestServer2 := TSQLRestServerDB.Create(Model2,':memory:',false);

 // serve aRestServer data over HTTP
 aHttpServer := TSQLHttpServer.Create(SERVER_PORT,[aRestServer],'+',useHttpApiRegisteringURI);
 aHttpServer.AddServer(aREstSErver2);

Offline

#3 2014-10-03 18:06:31

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: How mORMot access mutl database?

You can dispatch databases per server or even per table, but not per user.

IMHO one db per user sounds like a weird design.
It should better be one root / server per db.

Offline

#4 2014-10-04 01:44:44

ChinaPeng
Member
Registered: 2014-10-02
Posts: 15

Re: How mORMot access mutl database?

thanks Sabbiolina, ab 
i also think create  different root  for every database. but SQL SERVE have more than 1000 instance
It's not a good solution

Offline

#5 2014-10-04 10:06:01

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: How mORMot access mutl database?

1000 instances of SQL Server would be much more resource consuming that a root for each database.

A TSQLRestServer instance won't consume a lot of resources, and the same unique TSQLHttpServer instance is able to handle 1000 roots without any issue.

IMHO 1000 instances of SQL Server sounds like a weird choice.

Offline

Board footer

Powered by FluxBB