简体   繁体   English

JSON-MongoDB版本控制

[英]JSON - MongoDB versioning

I am trying to use JSON for application Configuration. 我正在尝试使用JSON进行应用程序配置。 I need some of the objects in the JSON to be dynamically crated(ex: Lookup from SQL database). 我需要动态创建JSON中的某些对象(例如:从SQL数据库中查找)。 It also needs to store the version history of the JSON file. 它还需要存储JSON文件的版本历史记录。 Since I want to go back and forth to switch from old configuration to a new configuration version. 由于我想来回切换从旧配置到新配置版本。

Initial thoughts were to put JSON on MongoDB and use placeholders for the dynamic part of the JSON object. 最初的想法是将JSON放在MongoDB上,并使用占位符作为JSON对象的动态部分。 Can someone give a guidance whether my thinking here is correct?(I am thinking of using JSON.NET for serialize/desiralize JSON object). 有人可以指导我这里的想法是否正确吗?(我正在考虑使用JSON.NET序列化/反序列化JSON对象)。 Thanks in advance. 提前致谢。

Edit: 编辑:

Ex: lets assume we have 2 Environments. 例如:假设我们有2个环境。 env1(v1.0.0.0) env2(v1.0.0.1) env1(v1.0.0.0)env2(v1.0.0.1)

**Env1** 

{

   id: env1 specific process id
   processname: process_name_specific_to_env1
   host: env1_specific_host_ip

   ...
   threads: 10(this is common across environments for V1.0.0.0 release)

}

**Env2** 

{

   id: env2 specific process id
   processname: process_name_specific_to_env2
   host: env2_specific_host_ip

   ...
   threads: 10(this is common across environments for V1.0.0.1 release)
   queue_size:15 (this is common across environments for V1.0.0.1 release)
}

what I want store is a common JSON file PER version. 我要存储的是一个通用的JSON文件PER版本。 The idea is if I want to upgrade the version lets say env1 to 1.0.0.1(from 1.0.0.0), should be able to take the v1.0.0.1 of JSON config and fill the env specific data from SQL and generate a new JSON). 这个想法是,如果我想将版本从env1升级到1.0.0.1(从1.0.0.0),应该能够使用JSON配置的v1.0.0.1并从SQL填充特定于env的数据并生成一个新的JSON)。 This way when moving environments from one release to another do not have to re do configuration. 这样,将环境从一个发行版迁移到另一个发行版时,无需重新配置。

 ex: 1.0.0.0 JSON file
{

   id: will be dynamically filled in from SQL
   processname: will be dynamically filled in from SQL
   host: will be dynamically filled in from SQL

   ...
   threads: 10(this is common across environments for V1.0.0.0 release))


}

=> generate a new file for any environment when requested. =>根据要求为任何环境生成一个新文件。

Hope I am being clear on what I am trying to achieve 希望我清楚我要实现的目标

As you said, you need some way to include the SQL part dynamically, that means manual joins in your application. 如您所说,您需要某种方式动态地包含SQL部分,这意味着在应用程序中进行手动联接。 Simple Ids referring to the other table should be enough, you don't need to invent a placeholder mechanism. 引用另一个表的简单ID就足够了,您无需发明一个占位符机制。

Choose which one is better for you: 选择哪个更适合您:

MongoDB to SQL reference MongoDB到SQL的参考

MongoDB MongoDB的

{
     "configParamA": "123", // ID of SQL row
     "configParamB": "456", // another SQL ID
     "configVersion": "2014-11-09"
}

SQL to MongoDB reference SQL到MongoDB的参考

MongoDB MongoDB的

{
     "configVersion": "2014-11-09"
}

SQL SQL

Just add a column with the configuration id, which is used in MongoDB, to every associated configuration row. 只需将MongoDB中使用的带有配置ID的列添加到每个关联的配置行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM