| In the development of relational databases and related technologies,SQL has always been used as the programming language for querying and processing data.However,because SQL has a description style of natural language,it is inconvenient to write and maintain directly during the development process.In the practical application,the database access layer is generally encapsulated,and the relevant API is used to construct SQL to complete the query.In this context,this paper studies and summarizes the existing database access layer,and proposes a improvement scheme of database access layer with formatted data conversion as the core,which solves the existing problem of chain call of database access layer chain call to some extent,including the problem of difficult reuse of logic and o'ver-coupling of API format and programming language.Therefore,in the field of data transmission,the forms of expression and technical means are also constantly improving,various of data exchange formats has been emerged.The main contents of this paper is as follows:In the application system,the database access layer is a relatively independent part,and needs to perform data transmission and exchange with other hierarchical structures to complete the work together.Therefore,in the field of data transmission,the forms of expression and technical means are also improving constantly,various of data exchange formats has been emerged.This paper researches the history and current situation of structured data development.Through comparison and selection,JSON is chosen as the language of interface description format and the research and implementation of the database access layer has been carried out based on this.In the research process of database access layer,through the analysis of the advantages and disadvantages of existing products,combining the current technical research status and actual product plans,and analyze the needs of the general user to operate the database,the basic functional definitions of database access layer are given.While satisfying the basic needs of database access layer users,the new plugin system has been added as the core of the extended function requirements.The introduction of the plugin model has made the code relatively independent which is not only can be developed separately,but is also convenient to declare through the interface to integrate its functionality into the overall architecture to use.The database access layer is optimized in some details while meeting the capabilities of database connection and query.First of all,for the definition of JSON interface,based on the analysis of some existing product API descriptions,the data format has been improved,the structured standard format has been defined,and the SQL-style compatible format has been provided to achieve full integration.Which means the database access layer is fully combine the features of the JSON format,and developers who are familiar to the SQL syntax can learn to use it quickly.Next,combine multiple supported format types in the converter,universal data format conversion scheme has been designed.Finally,the idea of adapter mode and decorator mode has been introduced,divided format conversion logic into two processes:preprocessing and modification.Both achieved decoupling on the implementation level,which provides convenience for the subsequent maintenance of the code.The research results are finally reflected in a complete set of JSON interface format definitions,ideas of converter design and code implementation on the Node.js platform,and a convenient way to interface with the MySQL database.Through the comparison of actual project application,the database access layer can reduce the number of lines and bytes of code by more than 30%,and strengthen the code readability,which is fully proved that it has certain functional value and significance for practical application. |