geddy / model

Datastore-agnostic ORM in JavaScript
265 stars 55 forks source link

SQL: Allow database name and schema be specified for each model #147

Closed salieri closed 1 year ago

salieri commented 10 years ago

In larger applications, data is often divided between schemas and databases.

This change allows developers to define schema and database for each model that uses Postgres or MySQL database adapters. (Schemas only supported on Postgres.)

Interface is simple -- when defining a model, just add "db" and/or "schema" values:

var User = function () {
  this.db = 'mydatabasename';
  this.schema = 'myschemaname';

  this.property( ...
mde commented 10 years ago

This looks good. Similar work is happening here: https://github.com/mde/model/pull/151 Would it be possible for y'all to coordinate to make sure this stuff plays nicely together?

salieri commented 10 years ago

By the looks of it, for a successful merge all that's needed is for me to go over the tableizeModelName() calls and make sure they use tableizeModelNameFull() instead where appropriate. Should not be a problem at all.

smitt04 commented 10 years ago

I think to make things a little more seemless is to just change the _tablelizedModelName function just like I did in #151. In that function you can check to see if a schema is defined or not. But it should be first merged with #151 and then the schema support added.

mde commented 10 years ago

Where are we on this? Can y'all get this sorted out, or do I need to do separate merges and then sort it out?

salieri commented 10 years ago

Will get back to you after crunch mode is over, give it a few weeks.

mde commented 10 years ago

Excellent. :) Lemme know if there's anything I can do to help.