Closed penguinpowernz closed 8 years ago
That is interesting, can you try running the examples at https://github.com/strongloop/loopback-example-kv-connectors and let me know if they work?
Yep that works. Why though? I notice that's running 3.0.0-alpha.5 of loopback, is the kv-redis connector only compatible with the 3.x versions? I haven't had any success swapping out loopback-connector-redis
for loopback-connector-kv-redis
in an established app, but I downgraded that to 2.34.1 from 3.0.0-alpha.5.
It should work for both versions (althought as you can see from my example, I'm using the latest master on GH -- 3.0.0-alpha.5). Would you like to help update the examples? We need it working for all versions (its WIP ATM -- almost release time after we work out the gremlins as you discovered).
I downgraded to 2.34.1 in the redis-lb2x and it still boots. I think the kv-redis connector doesn't work as I expect it to (i.e. doesn't want to store PersistedModel
) - judging by the Color model in there. Trying to find all PersistedModels (/api/animals
) results in this error:
{
"error": {
"name": "Error",
"status": 500,
"message": "Cannot call Animal.find(). The find method has not been setup. The PersistedModel has not been correctly attached to a DataSource!",
"stack": "Error: Cannot call Animal.find(). The find method has not been setup. The PersistedModel has not been correctly attached to a DataSource!\n at throwNotAttached (/home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/lib/persisted-model.js:68:11)\n at Function.find (/home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/lib/persisted-model.js:256:5)\n at SharedMethod.invoke (/home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/node_modules/strong-remoting/lib/shared-method.js:263:25)\n at HttpContext.invoke (/home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/node_modules/strong-remoting/lib/http-context.js:389:12)\n at phaseInvoke (/home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/node_modules/strong-remoting/lib/remote-objects.js:654:9)\n at runHandler (/home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/node_modules/loopback-phase/lib/phase.js:135:5)\n at iterate (/home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/node_modules/loopback-phase/node_modules/async/lib/async.js:146:13)\n at Object.async.eachSeries (/home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/node_modules/loopback-phase/node_modules/async/lib/async.js:162:9)\n at runHandlers (/home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/node_modules/loopback-phase/lib/phase.js:144:13)\n at iterate (/home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/node_modules/loopback-phase/node_modules/async/lib/async.js:146:13)\n at /home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/node_modules/loopback-phase/node_modules/async/lib/async.js:157:25\n at /home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/node_modules/loopback-phase/node_modules/async/lib/async.js:154:25\n at execStack (/home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/node_modules/strong-remoting/lib/remote-objects.js:493:7)\n at RemoteObjects.execHooks (/home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/node_modules/strong-remoting/lib/remote-objects.js:497:10)\n at phaseBeforeInvoke (/home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/node_modules/strong-remoting/lib/remote-objects.js:650:10)\n at runHandler (/home/robert/src/test2/loopback-example-kv-connectors/redis-lb2x/node_modules/loopback/node_modules/loopback-phase/lib/phase.js:135:5)"
}
}
Did you try with KVModel? Not supposed to use PersistedModel. See https://github.com/strongloop/loopback-example-kv-connectors/blob/master/redis-lb2x/common/models/color.json#L3
Yes the KVModel works... but now I realize that this is not what I want. I want a persisted model, persisted in Redis so went back to loopback-connector-redis
.
Using your example redis-lb2x app with 2.34.1 works fine, so I don't know what the loopback generator does differently.
I will close issue then. Please open a new issue if you are still running into issues.
I just made a fresh project using the following steps:
I chose 2.x stable for the version and api-server for the application.
Then I did
npm install --save loopback-connector-kv-redis
and modified mydatasources.json
file to look like this:Then I did
npm start
and I get this stacktrace:I didn't even create any models yet.
Here is the
package.json
file:The versions I ended up getting were the following:
loopback-boot@2.22.0
loopback@2.34.1
loopback-datasource-juggler@2.51.0
And here is the initial npm install output:
It also happens with the v3.x alpha release.