Closed bmatusiak closed 11 years ago
One plugin can provide multiple services, that should do what you need already.
In plugins/db/package.json
: "provides": [ "db.mongo", "db.mysql" ]
And in plugins/db/db-plugin.js
: register(null, { "db.mongo": {}, "db.mysql": {} })
.
And now app.users
can just consume db.mysql
. But it will come in as imports["db.mysql"]
.
I've a similar problem, I want to have a namespace called models
so I can create models and use them all at once in my API
plugin. I'd like my API to consume all the models without knowing their names to allow the end user to write their own model plugins.
For example:
Plugins/model-user/ Provides: models.user
Plugins/model-post/ Provides: models.post
Plugins/user-defined-model Provides: models.whoknows
Plugins/api/ Provides: API, Consumes: models
I could make a Model
plugin to collect the models in to a single object, but it feels a bit hackish. What do you think?
@jameswyse i found that you can run architect inside a plugin to its self
plugins/db/package.json
"provides": [ "db" ]
plugins/db/db-plugin.js
architect.createApp(config, function (err, DB) {
register(null, {
db : DB.services
});
});
basically nesting architect
Oh, that's an interesting solution! I'll give it a go.
@jameswyse Cool Let me know how it goes, your answer will be intriguing
@bmatusiak Interesting approach!
@janjongboom thanks for the :thumbsup:
Ok quick scenario
Lets say i want to provide a service as "db.mongo" and "db.mysql"
ok
lets say another plugin "app.users" consumes "db"
is it possible to render a object like
but! lets say i only want to consume "db.mysql"