javascript - Keystone.js: use one model in multiple sites -
i need create multiple sites using keystone.js (sites network). have reference collection, should used on every site relationship models in other network's sites. it's universal tags list used across network's site. hope understand mean. sorry bad english.
without understanding use case see 2 potential architectures explore:
single keystone instance:
see if can design data use inheritance , try putting sites in 1 keystone instance. ie have parent "post" model , per site "foopost", "barpost" inherits post. way use stock keystone/mongoose relationship mechanisms , built-in crud bootstraps. drawback here architecture make admin ui , data model more complicated think potential solution "partitioning" single keystone instance separate sites. might work better few "sites" on 1 instance more make data model , admin ux complicated use.
pros: can use keystone stock crud/relationships
cons: more complicated admin ux, you'll have manually partition front end out keep data separate, more complicated data structure using lot of inheritance
separate keystone instances:
a lightweight way share non-relational data between separate keystone instances (like common tag list) bootstrap api wrapper "tag" model each site , add api crud calls each keystone instance api . maintain model data across sites calling crud api via mongoose hooks. there plenty of examples out there boostrap keystone crud api , make api crud call within model's post save, post delete, or post update.
to model relationships more complicated. create "link" model on each site nothing more url field , _id. set 1 many relationship in models on each site trying share relationships , wrap link model in crud api. way "link" models , render out clickable links on admin pages. have code pretty fair amount of hook , api calls think potentially feasible architecture system can allow transactional data sync tolerance (ie wouldnt try type of architecture requires super tight transactional integrity ok social media).
pros: separation of concerns, cleaner data model, partitioned admin screens (maybe con use cases)
cons: need sync data model schema (you can submodule common keystone models github repo , share between sites fix problem ive done before), more api , schema hook code, each site has separate admin ux, more sysadmin work run , sync separate instances
Comments
Post a Comment