Waterline one-to-many with arbitrary foreign keys -
is possible have 1 sided one-to-many relationship between 2 models?
what i'm trying achieve plugin architecture, core app server has base set of models, specific implementation different clients can include custom data plugins.
so have notion of core entity
(super-simplified):
{ identity: 'entity', attributes: { id: 'integer', type: 'string' } }
ok, i'm going add passport
plugin store login credentials.
{ identity: 'passport', attributes: { id: 'integer', protocol: 'string', username: 'string', password: 'string', entity: { model: 'entity' } } }
so far good. want add user
plugin, user
extends entity
, user
can have number of passports. tried first:
{ identity: 'user', attributes: { id: 'integer', name: 'string', email: 'string', entity: { model: 'entity' }, passports: { collection: 'passport', via: 'entity' } } }
now things come unstuck in waterline (but it's reasonable data model). here's error:
trying associate collection attribute model doesn't have foreign key. user trying reference foreign key in passport
the point of exercise entity
rather abstract concept, , things passport
supposed add behaviour without having know concrete implementation (user
) looks like. because want plugin architecture, passport
can't know user
explicitly.
it otherwise quite elegant solution. there way coax waterline doing want? thanks.
Comments
Post a Comment