C2FO / patio

Idiomatic database toolkit

Home Page:http://c2fo.github.io/patio

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

multi database support

cvlmtg opened this issue · comments

I'm having some troubles with multi database support. If I do

model = patio.addModel "foobar"
model.sync().classic etc..

it works without problem, even in the coffee repl:

coffee> model.first().classic (e,r) -> console.log r.id
{ promise: [Function],
  chain: [Function],
  chainBoth: [Function],
  addCallback: [Function],
  addErrback: [Function],
  then: [Function],
  both: [Function],
  classic: [Function] }
coffee> 1801

but if I do:

conn = patio.createConnection uri
model = patio.addModel conn.from("foobar")
model.sync().classic etc..

nothing works anymore:

offee> model.first().classic (e,r) -> console.log r.id
{ promise: [Function],
  chain: [Function],
  chainBoth: [Function],
  addCallback: [Function],
  addErrback: [Function],
  then: [Function],
  both: [Function],
  classic: [Function] }
coffee>
repl:2
  return console.log(r.id);
                      ^
TypeError: Cannot read property 'id' of undefined
  at repl:2:23
  at spreadArgs (/Users/matteo/.nvf/installed/0.10.29/lib/node_modules/patio/node_modules/
comb/lib/base/functions.js:26:17)
  at Object._onImmediate (/Users/matteo/.nvf/installed/0.10.29/lib/node_modules/patio/node
_modules/comb/lib/promise.js:100:25)
  at processImmediate [as _immediateCallback] (timers.js:336:15)

I've re-read the doc and I'm pretty sure I'm doing nothing wrong...

if it can be of any help, patio.getModel(name, db) doesn't work either. It always says that the model hasn't been registered.

EDIT I'm erasing some of my comment here about the comb HashTable as I think I finally got it. I lost a little detail in between and didn't understand it correctly :)

anyway, it still seems that the model is added correctly inside the MODELS collection, but when you try to retrieve it, it has somehow disappeared. I'll see if I find some more spare time to debug it further.