view raw
Fribu Fribu - 5 months ago 69
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?


Found a solution

var modelName = req.param('p');