CN111198711A - Collection version control method and system based on MongoDB - Google Patents
Collection version control method and system based on MongoDB Download PDFInfo
- Publication number
- CN111198711A CN111198711A CN202010033770.1A CN202010033770A CN111198711A CN 111198711 A CN111198711 A CN 111198711A CN 202010033770 A CN202010033770 A CN 202010033770A CN 111198711 A CN111198711 A CN 111198711A
- Authority
- CN
- China
- Prior art keywords
- class
- entity
- creating
- module
- mongodb
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
- G06F8/315—Object-oriented languages
Abstract
The invention relates to a Collection version control method and a system based on MongoDB, which comprises the steps of creating a domain Entity base class Entity, creating each domain Entity class, creating a custom configuration attribute class Settings, creating a context interface class Icontext, creating a database context implementation DataContext class, creating a data storage generic interface class IRepositivity < T >, creating a service logic implementation class, initializing a global variable of the context interface class IContext in a construction function of the created service logic implementation class and a domain instance class set version number in the MongoDB to be operated. The invention has clear code logic, is easy to manage, is convenient for realizing some service logics and can well solve the problem of data disorder when the integrated data structure in the project is complex and the later integrated data volume is large.
Description
Technical Field
The invention belongs to the technical field of data processing, relates to a Collection version control method and system, and particularly relates to a MongoDB-based Collection version control method and system.
Background
MongoDB is a database based on distributed file storage, is written in C + + language and aims to provide an extensible high-performance data storage solution for WEB application. MongoDB is a product between relational databases and non-relational databases, and among the non-relational databases, the MongoDB has the most abundant functions and is most similar to the relational databases. The data structure supported by the method is very loose and is in a json-like bson format, so that more complex data types can be stored. The biggest characteristic of Mongo is that the query language supported by Mongo is very strong, the syntax of Mongo is similar to the object-oriented query language, most functions of single-table query of similar relational databases can be almost realized, and index establishment of data is also supported. The MongoDB server can run on a Linux, Windows or mac os x platform, supports 32-bit and 64-bit applications, and has a default port of 27017. It is recommended to run on a 64-bit platform because the maximum file size supported by MongoDB when running in 32-bit mode is 2 GB. A MongoDB instance may contain a set of databases, a DataBase may contain a set of collections, and a Collection may contain a set of documents. A Document contains a set of fields, each of which is a key/value pair.
In the prior art, in a project for processing data integration, because data content needing to be integrated is complex in structure and frequent in change, storage management of the data integration by adopting MongoDB is an optimal scheme, and distributed deployment is easier to perform when the later-stage integration data amount is large. However, for scenarios where the integrated content changes frequently, there are generally two solutions:
1) the method is a good choice for scenes with simple integrated data structure and small data size.
2) The disadvantages of the scheme 1) are reflected fully when the integrated data structure is complex and the amount of later-stage integrated data is large, and for this reason, the integrated data of different integrated content versions are managed in different collections, however, how to operate the Collection data of different integrated content versions by using a set of data service interfaces aiming at a certain field still has a problem.
Disclosure of Invention
In order to solve the technical problems in the background art, the invention provides a MongoDB-based Collection version control method and system which have clear code logic, are easy to manage and convenient for realizing some service logics and can well solve the problem of data clutter when the integrated data structure is complex and the later-stage integrated data amount is large in a project.
In order to achieve the purpose, the invention adopts the following technical scheme:
a MongoDB-based Collection version control method is characterized by comprising the following steps: the MongoDB-based Collection version control method comprises the following steps of:
1) creating a domain Entity base class Entity, wherein two attributes of a primary key and creation time are defined, the primary key is marked with two characteristics of BsonId and BsonReresentation, and other domain entities are inherited from the base class;
2) creating each domain Entity class, wherein each domain Entity class inherits the Entity base class Entity created in the step 1);
3) creating custom configuration attribute types, wherein two attributes of a connection character string of MongoDB and an operation database name are defined and are used for reading custom global variable values in an application configuration file;
4) creating a context interface class IContext, wherein a database set Version attribute and a plurality of field entity IMongoCollection extensive sets created in the step 2) are defined;
5) creating a database context realization body DataContext class, wherein the database context realization body DataContext class inherits the context interface class IContext created in the step 4), and instantiating a MongoDB database global read-only variable with the type of IMontoDatabase, an initialized database set Version attribute value and an instantiated field entity IMontoColection extensive set in a construction function of the class DataContext;
6) creating a data storage generic interface class IRepositivity < T >, wherein the type T inherits the Entity base class Entity created in the step 1), and defining various service method statements for the field Entity data operation created in the step 2) in the class, so that the creation of the core class information is completed;
7) creating a service logic implementation class, wherein the service logic implementation class is inherited from the data storage generic interface class IRepositivity < T > created in the step 6), and T is a certain field entity class created in the step 2);
8) initializing a global variable of a context interface class IContext and a field instance class set version number in MongoDB to be operated in the constructor of the service logic implementation class created in the step 7), wherein all kinds of operation of the field instance class set are set data of the initialization version number by using the global variable of the context interface class IContext.
The specific way of the statement in the step 6) is as follows: synchronous or asynchronous.
A Collection version control system based on MongoDB is characterized in that: the MongoDB-based Collection version control system comprises:
the base class module defines the commonalities of all entities, the internal base class of the method comprises the commonalities of a primary key and the creation time, and the classes in other fields are integrated with the base class;
the entity class module is mainly used as a class existing on a data management and service logic processing level, and mainly has the main responsibility of distinguishing the entity class in an analysis stage to store and manage information in a system;
the interface module comprises a reference type for defining an agreement and is used for defining a method in business logic operation;
the realization module focuses on system design related to service requirements, such as the formulation of service rules, the realization of service flows and the like;
the connection module is used for realizing connection and inheritance of the MongDB and logically realizing a method for defining the connection interface, and various operations for realizing the class module set are set data of an initialization version number by utilizing a global variable at the end of the context connection interface;
the connection interface module is a logic interface for defining and operating the MongDB layer;
the connection module defines two attributes of a global character string connecting the MongDB and the operation database;
the base class module is accessed to the implementation class module through the entity class module and the interface module; the connection module is connected with the realization module through the connection interface module and the connection module.
The invention has the advantages that:
the invention provides a Collection version control method and a system based on MongoDB, the method comprises the steps of creating domain Entity base class Entity, creating various domain Entity classes, creating custom configuration attribute classes, creating a context interface class Icontext, creating a database context implementation body DataContext class, creating a data storage generic interface class IRepositivity < T >, creating a service logic implementation class, initializing a global variable of the context interface class IContext in a construction function of the service logic implementation class created in the step 7) and a domain instance class set version number in the MongoDB to be operated, and thus, using the global variable of the context interface class IContext to set various operations of the domain instance class set into set data of initialization version numbers. The code logic of the invention is clear, and the invention is easy to be managed; historical data is reserved, so that the realization of some business logics is facilitated; the problem that data are messy when the integrated data structure is complex and the later-stage integrated data volume is large in the project can be well solved.
Drawings
FIG. 1 is a flow chart of a MongoDB-based Collection version control method provided by the invention;
FIG. 2 is a frame diagram of a MongoDB-based Collection version control system provided by the present invention.
Detailed Description
Referring to fig. 1, the present invention provides a Collection version control method based on montgodb, which comprises the following steps:
1) creating a domain Entity base class Entity, wherein two attributes of a primary key and creation time are defined, the primary key is marked with two characteristics of BsonId and BsonRelocation (BsonType. ObjectId), and other domain entities are inherited from the base class;
2) creating Entity classes of each field, wherein the Entity classes need to inherit the base class Entity created in the step 1);
3) creating custom configuration attribute types, wherein two attributes of a connection character string and an operation database name of the MongoDB are defined and are used for reading custom global variable values in an application configuration file;
4) creating a context interface type IContext, wherein a database set Version attribute and a plurality of field entity IMontogoCollection extensive sets created in the step 2) are defined;
5) creating a database context implementer DataContext class, inheriting the context interface class IContext created in the step 4), instantiating a MongoDB database global read-only variable with the type of IMontogDatabase in a constructor of the class DataContext, initializing a database set Version attribute value, instantiating a domain entity IMontogoCollection extensive set (a set name instantiation rule: set name + underline + Version number Version attribute value);
6) creating a data warehousing generic interface class IRepositivity < T >, wherein the class T inherits the base class Entity created in the step 1), and defining various service method statements (synchronous/asynchronous increase, deletion, check and the like) for the field Entity data operation created in the step 2) in the class, so that the creation of the core class information is completed;
7) creating a service logic implementation class, which is inherited from the data storage generic interface class IRepositivity < T > created in the step 6), wherein T is a specific entity class in a certain field created in the step 2);
8) initializing a global variable of a context interface class IContext and a field instance class set version number in MongoDB to be operated in the service logic implementation class constructor created in the step 7), so that all kinds of operation of the field instance class set are set data of the initialized version number by using the global variable of the context interface class IContext; if data information in the appointed version set is required to be inquired, a version number input parameter can be added in the inquiry business method, and the version number of the global variable of the context interface class IContext is subjected to value reassignment in the business method body.
Referring to fig. 2, the present invention further provides a Collection version control system based on the montgodb, the control system comprising:
base class module: the base class is the most basic module, wherein the common property of all entities is defined, the internal base class of the method comprises the common property of a main key and the creation time, and the base class must be integrated by the classes in other fields;
an entity class module: the entity class module is mainly used as a category existing on the data management and business logic processing level, the main responsibility of the entity class module in the analysis stage is to store and manage information in a system, the entity class module can also have behaviors and even complex behaviors, and the behaviors are closely related to entity objects represented by the entity class module;
an interface module: the interface module contains a reference type that defines an agreement. Other types implement interfaces to ensure that they support certain operations. An interface specifies the members that must be provided by a class or other interface that implements it. Similar to classes, interfaces may contain methods, attributes, indexers, and events as members. Including the definition of a particular operation;
and (3) realizing a class module: the implementation class module is also called business logic Layer (business logic Layer) as the core part of the method. The attention point of the system is mainly focused on system design related to business requirements, such as the formulation of business rules, the realization of business processes and the like, namely the system is related to Domain logic corresponding to the system, and a business logic layer is also called as a Domain layer in many times;
connecting the modules: realizing connection and inheritance of the MongDB and logic realization of a method for defining the connection interface, so that all kinds of operation for realizing a class module set are set data of an initialization version number by utilizing a global variable at the end of a context connection interface;
connecting the interface module: the module is similar to an interface module, the module is used for defining a method in business logic operation, and most of the module is a logic interface for defining and operating a MongDB layer;
a connecting module: the module defines two attributes of a global character string connecting the MongDB and an operation database, and lays a foundation for connecting and operating the MongDB.
Claims (3)
1. A MongoDB-based Collection version control method is characterized by comprising the following steps: the MongoDB-based Collection version control method comprises the following steps of:
1) creating a domain Entity base class Entity, wherein two attributes of a primary key and creation time are defined, the primary key is marked with two characteristics of BsonId and BsonReresentation, and other domain entities are inherited from the base class;
2) creating each domain Entity class, wherein each domain Entity class inherits the Entity base class Entity created in the step 1);
3) creating custom configuration attribute types, wherein two attributes of a connection character string of MongoDB and an operation database name are defined and are used for reading custom global variable values in an application configuration file;
4) creating a context interface class IContext, wherein a database set Version attribute and a plurality of field entity IMongoCollection extensive sets created in the step 2) are defined;
5) creating a database context realization body DataContext class, wherein the database context realization body DataContext class inherits the context interface class IContext created in the step 4), and instantiating a MongoDB database global read-only variable with the type of IMontoDatabase, an initialized database set Version attribute value and an instantiated field entity IMontoColection extensive set in a construction function of the class DataContext;
6) creating a data storage generic interface class IRepositivity < T >, wherein the type T inherits the Entity base class Entity created in the step 1), and defining various service method statements for the field Entity data operation created in the step 2) in the class, so that the creation of the core class information is completed;
7) creating a service logic implementation class, wherein the service logic implementation class is inherited from the data storage generic interface class IRepositivity < T > created in the step 6), and T is a certain field entity class created in the step 2);
8) initializing a global variable of a context interface class IContext and a field instance class set version number in MongoDB to be operated in the constructor of the service logic implementation class created in the step 7), wherein all kinds of operation of the field instance class set are set data of the initialization version number by using the global variable of the context interface class IContext.
2. The MongoDB-based Collection version control method according to claim 1, wherein: the specific way of the statement in the step 6) is as follows: synchronous or asynchronous.
3. A Collection version control system based on MongoDB is characterized in that: the MongoDB-based Collection version control system comprises:
the base class module defines the commonalities of all entities, the internal base class of the method comprises the commonalities of a primary key and the creation time, and the classes in other fields are integrated with the base class;
the entity class module is mainly used as a class existing on a data management and service logic processing level, and mainly has the main responsibility of distinguishing the entity class in an analysis stage to store and manage information in a system;
the interface module comprises a reference type for defining an agreement and is used for defining a method in business logic operation;
the realization module focuses on system design related to service requirements, such as the formulation of service rules, the realization of service flows and the like;
the connection module is used for realizing connection and inheritance of the MongDB and logically realizing a method for defining the connection interface, and various operations for realizing the class module set are set data of an initialization version number by utilizing a global variable at the end of the context connection interface;
the connection interface module is a logic interface for defining and operating the MongDB layer;
the connection module defines two attributes of a global character string connecting the MongDB and the operation database;
the base class module is accessed to the implementation class module through the entity class module and the interface module; the connection module is connected with the realization module through the connection interface module and the connection module.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010033770.1A CN111198711B (en) | 2020-01-13 | 2020-01-13 | Collection version control method and system based on MongoDB |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010033770.1A CN111198711B (en) | 2020-01-13 | 2020-01-13 | Collection version control method and system based on MongoDB |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111198711A true CN111198711A (en) | 2020-05-26 |
CN111198711B CN111198711B (en) | 2023-02-28 |
Family
ID=70747275
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010033770.1A Active CN111198711B (en) | 2020-01-13 | 2020-01-13 | Collection version control method and system based on MongoDB |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111198711B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112711405A (en) * | 2020-12-28 | 2021-04-27 | 山东浪潮通软信息科技有限公司 | Method, equipment and storage medium for generating add-delete-modify-check application program interface |
CN116540997A (en) * | 2023-07-07 | 2023-08-04 | 杭州朗和科技有限公司 | Data type declaration method, medium, device and computing equipment |
Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103109290A (en) * | 2010-07-23 | 2013-05-15 | 谷歌公司 | Encoding a schema version in table names |
CN104429048A (en) * | 2012-05-07 | 2015-03-18 | 瑞典爱立信有限公司 | Object version management |
CN105956087A (en) * | 2016-04-29 | 2016-09-21 | 清华大学 | Data and code version management system and method |
CN106164897A (en) * | 2013-12-02 | 2016-11-23 | 丘贝斯有限责任公司 | For depositing the system and method for memory database |
CN106844643A (en) * | 2017-01-13 | 2017-06-13 | 王洋 | A kind of Database Dynamic generation method based on template engine |
CN107330014A (en) * | 2017-06-15 | 2017-11-07 | 武汉斗鱼网络科技有限公司 | The creation method and equipment of a kind of tables of data |
US10089108B1 (en) * | 2015-06-17 | 2018-10-02 | Amazon Technologies, Inc. | Archival format for incremental deployments and version control |
CN109992279A (en) * | 2017-12-30 | 2019-07-09 | 中国移动通信集团山西有限公司 | Method for updating configuration data, calculates equipment and storage medium at device |
CN110245178A (en) * | 2019-07-15 | 2019-09-17 | 上海矩云信息技术有限公司 | Marketing automation management platform system and its management method |
US10459647B1 (en) * | 2017-03-02 | 2019-10-29 | Amazon Technologies, Inc. | Multiple storage class representation in versioned storage |
-
2020
- 2020-01-13 CN CN202010033770.1A patent/CN111198711B/en active Active
Patent Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103109290A (en) * | 2010-07-23 | 2013-05-15 | 谷歌公司 | Encoding a schema version in table names |
CN104429048A (en) * | 2012-05-07 | 2015-03-18 | 瑞典爱立信有限公司 | Object version management |
CN106164897A (en) * | 2013-12-02 | 2016-11-23 | 丘贝斯有限责任公司 | For depositing the system and method for memory database |
US10089108B1 (en) * | 2015-06-17 | 2018-10-02 | Amazon Technologies, Inc. | Archival format for incremental deployments and version control |
CN105956087A (en) * | 2016-04-29 | 2016-09-21 | 清华大学 | Data and code version management system and method |
CN110119393A (en) * | 2016-04-29 | 2019-08-13 | 清华大学 | Code release management system and method |
CN106844643A (en) * | 2017-01-13 | 2017-06-13 | 王洋 | A kind of Database Dynamic generation method based on template engine |
US10459647B1 (en) * | 2017-03-02 | 2019-10-29 | Amazon Technologies, Inc. | Multiple storage class representation in versioned storage |
CN107330014A (en) * | 2017-06-15 | 2017-11-07 | 武汉斗鱼网络科技有限公司 | The creation method and equipment of a kind of tables of data |
CN109992279A (en) * | 2017-12-30 | 2019-07-09 | 中国移动通信集团山西有限公司 | Method for updating configuration data, calculates equipment and storage medium at device |
CN110245178A (en) * | 2019-07-15 | 2019-09-17 | 上海矩云信息技术有限公司 | Marketing automation management platform system and its management method |
Non-Patent Citations (3)
Title |
---|
BHATTACHERJEE S ET AL.: "RStore: efficient multiversion document management in the cloud", 《THE 2017 SYMPOSIUM. ACM》 * |
佚名: "MongoDB中文档集的版本控制", 《IT1352 HTTPS://WWW.IT1352.COM/600794.HTML》 * |
侯景伟 等: "海绵城市云空间数据库设计与实现(英文)", 《中南大学学报(英文版)》 * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112711405A (en) * | 2020-12-28 | 2021-04-27 | 山东浪潮通软信息科技有限公司 | Method, equipment and storage medium for generating add-delete-modify-check application program interface |
CN116540997A (en) * | 2023-07-07 | 2023-08-04 | 杭州朗和科技有限公司 | Data type declaration method, medium, device and computing equipment |
CN116540997B (en) * | 2023-07-07 | 2023-09-26 | 杭州朗和科技有限公司 | Data type declaration method, medium, device and computing equipment |
Also Published As
Publication number | Publication date |
---|---|
CN111198711B (en) | 2023-02-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7152070B1 (en) | System and method for integrating and accessing multiple data sources within a data warehouse architecture | |
US6829606B2 (en) | Similarity search engine for use with relational databases | |
US6704747B1 (en) | Method and system for providing internet-based database interoperability using a frame model for universal database | |
US6076090A (en) | Default schema mapping | |
US5295256A (en) | Automatic storage of persistent objects in a relational schema | |
US6611844B1 (en) | Method and system for java program storing database object entries in an intermediate form between textual form and an object-oriented form | |
US6356913B1 (en) | Generic (database-independent) and dynamically-modifiable schema | |
US6606632B1 (en) | Transforming transient contents of object-oriented database into persistent textual form according to grammar that includes keywords and syntax | |
US7603374B2 (en) | Dynamically generating multiple hierarchies of inter-object relationships based on object attribute values | |
US6598052B1 (en) | Method and system for transforming a textual form of object-oriented database entries into an intermediate form configurable to populate an object-oriented database for sending to java program | |
US20060195460A1 (en) | Data model for object-relational data | |
US20030208493A1 (en) | Object relational database management system | |
US7289997B1 (en) | System and method for an extensible metadata driven application framework | |
US6542899B1 (en) | Method and system for expressing information from an object-oriented database in a grammatical form | |
US20100145986A1 (en) | Querying Data and an Associated Ontology in a Database Management System | |
KR20060045622A (en) | Extraction, transformation and loading designer module of a computerized financial system | |
EP2122458A2 (en) | Querying data and an associated ontology in a database management system | |
JP2004280823A (en) | Automatic generation of dimensional model for business analysis from object model for online transaction processing | |
CN111198711B (en) | Collection version control method and system based on MongoDB | |
WO2019015364A1 (en) | Method and device for executing structured query language (sql) instruction | |
CN110502667A (en) | The parsing of ODX document and generation technique based on DOM frame | |
US20220035820A1 (en) | Storage structure of data object, method and system for storing and dynamically managing data object on computer, and storage medium and electronic device | |
Silvescu et al. | Graph databases | |
CN109359128A (en) | The method of mapping is realized between objective system and relational system | |
You et al. | Relational DB Implementation of STEP based product model |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |