Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

where to add prefixes to tables? #203

Closed
calidion opened this issue Jun 19, 2013 · 9 comments
Closed

where to add prefixes to tables? #203

calidion opened this issue Jun 19, 2013 · 9 comments

Comments

@calidion
Copy link

where to add prefixes to tables?

@dresende
Copy link
Owner

You mean a generic prefix?

@calidion
Copy link
Author

for example.

i have a range of test models in the same database.

for the same model user, i can test different sets with the only need to change the prefix.

for

models.setPrefix("pre_");

models.define('user')
,
table pre_user will be visited

if i use
models.setPrefix('aaa__');
models.define('user')
then
aaa_user will be visited.

@dresende
Copy link
Owner

Ok, this can be an option. If I understood, you need something like:

var orm = require("orm");

orm.connect("....", function (err, db) {
    db.settings.set("models.namePrefix", "pre_"); // not sure the settings name is this

    var Person1 = db.define("person", { // will use table "pre_person"
        // ...
    });

    // ...

    db.settings.unset("models.namePrefix");

    var Person2 = db.define("person", { // will use table "person"
        // ...
    });
});

@calidion
Copy link
Author

yes, it works now?

@dresende
Copy link
Owner

No but I'll do it :)

dresende added a commit that referenced this issue Jun 19, 2013
When set, is the prefix for subsequent db.define() table names (if no
table or collection is passed in options)
@dresende
Copy link
Owner

The setting name is actually model.namePrefix. Please try it.

@calidion
Copy link
Author

great! but after npm update, it seems the package not updated yet.

@dresende
Copy link
Owner

Yes, I need to close some things before publishing a new version. For now you might want to try:

npm install dresende/node-orm2

It should fetch directly from github.

@calidion
Copy link
Author

thanks, i will wait for your update:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants