Fribu Fribu - 1 year ago 124
Node.js Question

Sailsjs: dynamic tableName in model

I am building my first sailsjs and nodejs application, and it great :)

My situation, I have about 100 tables with the same stucture, I would like to decide "on the fly" which table to load.

my first thought was use somehow a dynamic class names. But I dont know how to do this with nodejs, maybe some one have an idea.

So I would create 100 "modelName".js files in my models folder.

I can use this in browser


But I don't have any window object in nodejs

Second idea was to pass the tableName to the model, the problem is, I have to reinit the model, don't know how.

Any solutions?

Answer Source

Found a solution

var modelName = req.param('p');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download