CN111198711B - Collection version control method and system based on MongoDB - Google Patents
Collection version control method and system based on MongoDB Download PDFInfo
- Publication number
- CN111198711B CN111198711B CN202010033770.1A CN202010033770A CN111198711B CN 111198711 B CN111198711 B CN 111198711B CN 202010033770 A CN202010033770 A CN 202010033770A CN 111198711 B CN111198711 B CN 111198711B
- 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.)
- Active
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 supported query language is very strong, the syntax is similar to an object-oriented query language, most functions of single-table query of a similar relational database can be almost realized, and index establishment of data is 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 2GB. 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 to the greatest extent when the integrated data structure is complex and the later integrated data amount is large, and for this reason, the integrated data of different integrated content versions are considered to be put into different collections for management, however, how to use a set of Collection data aiming at a data service interface in a certain field to operate different integrated content versions 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 Collection version control method based on MongoDB is characterized in that: the Collection version control method based on MongoDB 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 BsonReresentation, and other domain entities are inherited from the base class;
2) Creating Entity classes of each field, wherein the Entity classes of each field inherit from 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), 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 IMontoCollection extensive set in a construction function of the class DataContext, and the set name instantiation rule is a set name + underline + Version number Version attribute value;
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 entity 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 entity 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 base class in the method comprises the commonalities of a primary key and the creation time, and the classes in other fields must inherit the base class;
the entity class module is mainly used as a class existing on a data management and service logic processing layer, and the main role of distinguishing the entity class in the analysis stage is 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; creating a context interface type IContext, wherein a database set Version attribute is defined;
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 succession of the MongDB and logically realizing a method for defining a connection interface, and various operations of the entity module set are set data of an initialization version number by using a global variable of a context connection interface IContext;
the connection interface module is used for defining a logic interface for 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 the Collection version control system based on MongoDB provided by the present invention.
Detailed Description
Referring to fig. 1, the invention provides a Collection version control method based on montgodb, comprising 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 IRepository < 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 entity class set version number in MongoDB to be operated in the service logic realization class constructor created in the step 7), so that all kinds of operation of the field entity 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 designated version set is to be queried, a version number input parameter can be added in a query business method, and the version number attribute of the global variable of the context interface class IContext is re-assigned 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:
and (3) a base class module: the base class is the most basic module, wherein the common property of all entities is defined, the base class in the method comprises the common property as a main key and the creation time, and the classes in other fields must inherit the base class;
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 member that must be provided by a class or other interface on which it is implemented. 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 of an entity module set are set data of an initialization version number by using a global variable of a context connection interface type IContext;
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 Collection version control method based on MongoDB is characterized in that: 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), 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 IMontoCollection extensive set in a construction function of the class DataContext, and the set name instantiation rule is a set name + underline + Version number Version attribute value;
6) Creating a data storage generic interface class IRepository < T >, wherein the type T inherits the Entity base class Entity created in the step 1), and defining various business method declarations 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 entity class set version number in the MongoDB to be operated in the constructed function of the service logic implementation class created in the step 7), and using the global variable of the context interface class IContext to carry out all kinds of operation on the field entity class set to be set data of the initialized version number.
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 MongoDB-based Collection version control system is characterized in that: the Collection version control system based on MongoDB comprises:
the base class module defines the commonalities of all entities, the commonalities are main keys and creation time, and classes in other fields must inherit the base class;
the entity class module is mainly used as a class existing on a data management and service logic processing layer, and the main role of distinguishing the entity class in the analysis stage is 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; creating a context interface class IContext, wherein a database set Version attribute and a plurality of created field entity IMontogoCollection extensive sets are defined; creating a database context realization body DataContext class, wherein the database context realization body DataContext class is inherited from a context interface class IContext, instantiating a MongoDB database global read-only variable with the type of IMontogatabase, an initialized database set Version attribute value and an instantiated field entity IMontogoCollection extensive set in a constructor of the class DataContext, and an aggregation name instantiation rule is an aggregation name + underline + Version attribute value;
the realization module focuses on the establishment of business rules and the realization of business processes and the system design related to business requirements;
the connection module is used for realizing connection and succession of the MongDB and logic realization of a connection interface definition method, and various operations of the entity module set are set data of an initialization version number by using a global variable of a context connection interface IContext;
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 CN111198711A (en) | 2020-05-26 |
CN111198711B true 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) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112711405B (en) * | 2020-12-28 | 2022-10-25 | 浪潮通用软件有限公司 | Method, equipment and storage medium for generating add-delete-modify-check application program interface |
CN116540997B (en) * | 2023-07-07 | 2023-09-26 | 杭州朗和科技有限公司 | Data type declaration method, medium, device and computing equipment |
Citations (8)
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 |
CN106844643A (en) * | 2017-01-13 | 2017-06-13 | 王洋 | A kind of Database Dynamic generation method based on template engine |
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 |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CA2932403A1 (en) * | 2013-12-02 | 2015-07-02 | Qbase, LLC | Systems and methods for hosting an in-memory database |
CN107330014B (en) * | 2017-06-15 | 2021-04-09 | 武汉斗鱼网络科技有限公司 | Data table creating method and device |
-
2020
- 2020-01-13 CN CN202010033770.1A patent/CN111198711B/en active Active
Patent Citations (9)
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 |
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 |
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 |
---|
MongoDB中文档集的版本控制;佚名;《IT1352 https://www.it1352.com/600794.html》;20170319;全文 * |
RStore: efficient multiversion document management in the cloud;Bhattacherjee S et al.;《the 2017 Symposium. ACM》;20170924;全文 * |
海绵城市云空间数据库设计与实现(英文);侯景伟 等;《中南大学学报(英文版)》;20181031;第25卷(第10期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN111198711A (en) | 2020-05-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7152070B1 (en) | System and method for integrating and accessing multiple data sources within a data warehouse architecture | |
Candel et al. | A unified metamodel for NoSQL and relational databases | |
US6704747B1 (en) | Method and system for providing internet-based database interoperability using a frame model for universal database | |
US6606632B1 (en) | Transforming transient contents of object-oriented database into persistent textual form according to grammar that includes keywords and syntax | |
US5295256A (en) | Automatic storage of persistent objects in a relational schema | |
US6829606B2 (en) | Similarity search engine for use with relational databases | |
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 | |
US6298354B1 (en) | Mechanism and process to transform a grammar-derived intermediate form to an object-oriented configuration database | |
US8352478B2 (en) | Master data framework | |
US20030208493A1 (en) | Object relational database management system | |
US20060195460A1 (en) | Data model for object-relational data | |
US6968344B2 (en) | Method and apparatus for object-oriented access to a relational database management system (RDBMS) based on any arbitrary predicate | |
US20100145986A1 (en) | Querying Data and an Associated Ontology in a Database Management System | |
US20050108206A1 (en) | System and method for object-oriented interaction with heterogeneous data stores | |
EP1030248A1 (en) | Grammar to represent a hierarchical object-oriented database | |
CN111198711B (en) | Collection version control method and system based on MongoDB | |
US20070067323A1 (en) | Fast file shredder system and method | |
WO2019015364A1 (en) | Method and device for executing structured query language (sql) instruction | |
US20100088685A1 (en) | System and method for mapping a domain modeling language to a relational store | |
You et al. | Relational DB Implementation of STEP based product model | |
CN112256927A (en) | Method and device for processing knowledge graph data based on attribute graph | |
Rajugan et al. | XML views: Part 1 | |
He | Formalizing UML class diagrams-a hierarchical predicate transition net approach | |
Bertino et al. | Applications of object-oriented technology to the integration of heterogeneous database systems | |
US8244778B1 (en) | Customization of types using default aspects |
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 |