J
J
JohnxFFF2019-11-11 07:27:48
Node.js
JohnxFFF, 2019-11-11 07:27:48

How to properly organize settings for subdomains?

There is:

  • General settings for the entire site and subdomains (for example, whether the site is disabled, etc.)
  • Settings for the subdomain (name, city, etc.)
  • Custom settings, that is, in the settings you add a key: value

+ for some settings will be multilingual, for example "site name", you need to store in different languages ​​The
question is how to gracefully organize the work and storage of these settings, if:
1. When creating a subdomain, you need to copy all the settings for it that are on other subdomains
2 .When creating a custom field, add it to all subdomains.
So far I've implemented it like this: There is a setting
table :
id | name | value | site_id | lang_id | autoload | type

where:
site_id - the subdomain itself lang_id - autoload
language
- autoload, it's clear here
type - setting type ( 0 - General, for the entire site, 1 - For the main domain (which cannot be deleted, 2 - Custom settings)
But it seems to me very crutch scheme, but I don’t see another yet, tell me please, how to properly organize such functionality?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stockholm Syndrome, 2018-10-18
@NikFedoseev

more or less like this:

async function f() {
  let payload = {}; 

  let schedule = await parser(); 
  payload.message = schedule[0].date;

  return payload;
}

// использование
f().then((payload) => {
  console.log(payload);
});

I
Ivan Melnikov, 2019-11-11
@JohnxFFF

I recently had a very similar problem, but not about settings and subdomains, but about the schedule for turning on / off street lighting in cities and city districts (you can see my questions).
I came up with this solution (in terms of your task):
I like this scheme because the newly created domain inherits settings from its "parents" without new entries in the Assignment table . But at the same time, nothing prevents you from explicitly customizing the settings for this domain by adding entries to the Assignment table . The external code first looks in the Assignment for the settings for this domain, if they are not there, then the settings of the parents will be applied.
I would like to hear criticism of this version of the scheme, since it is my invention (probably not unique) and I am not completely sure of it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question