Database processing method and apparatus, electronic device, and readable storage medium
By monitoring database version number changes through auto-incrementing version numbers and dynamically creating data tables, the problem of IndexedDB's inability to dynamically create data tables is solved, improving database operation efficiency and reducing costs.
Patent Information
- Application Number
- CN202310971126.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-03
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2043-08-03
AI Technical Summary
In existing technologies, IndexedDB cannot dynamically create data tables and table structures during use, resulting in high costs and low efficiency in structured data caching operations, which cannot meet user needs.
By monitoring changes in the database version number using an auto-incrementing version number, new data tables can be dynamically created, thus enabling dynamic table creation in the database.
It improves database operation efficiency, reduces the operational cost of structured data caching, and meets various user needs.
Smart Images

Figure CN116795888B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and more specifically, to a database processing method, apparatus, electronic device, and readable storage medium. Background Technology
[0002] When using computers and other electronic devices in daily life, poor network conditions or application system defects and anomalies can lead to data loss or inability to troubleshoot problems. In such cases, it is common practice to first cache structured data in the database, which can automatically report data at any time, helping to prevent data loss and improve the efficiency of problem troubleshooting.
[0003] Currently, IndexedDB only allows setting the data table structure in advance, and it cannot dynamically create data tables and table structures during use. This results in limitations on various database functions, high operational costs and low efficiency when caching structured data, and fails to meet user needs. Summary of the Invention
[0004] In view of this, the purpose of the embodiments of this application is to provide a database processing method, apparatus, electronic device and readable storage medium to improve the problems of high operating cost and low efficiency in the prior art when performing structured data caching.
[0005] To address the aforementioned problems, in a first aspect, embodiments of this application provide a database processing method, the method comprising:
[0006] Based on the operation instructions of the target database, query whether there are corresponding historical data tables in all the initial data tables of the target database;
[0007] If the historical data table does not exist in the target database, the update version number is determined based on the initial version number of the target database;
[0008] A new data table is created in the target database based on the updated version number.
[0009] In the above implementation process, it is possible to query whether there is a corresponding historical data table based on the operation instructions of the target database. If there is no historical data table, the database is processed by incrementing the version number to monitor changes in the database version number. The new data table is dynamically created based on the updated version number when the version number changes, thereby realizing the function of dynamically creating data tables during database use. This effectively improves the operational efficiency of the database, thereby reducing the operational cost of structured data caching, improving the efficiency of structured data caching, and meeting various user needs.
[0010] Optionally, the target database is determined in the following manner:
[0011] Set the configuration parameters for the initial database;
[0012] The initial database is initialized according to the configuration parameters to obtain the target database.
[0013] In the above implementation process, to set up multiple corresponding data tables in the target database, the initial database can be initialized. During configuration, corresponding configuration parameters can be preset and stored using the built-in structure tables of the initial database, thereby initializing the initial database and obtaining a usable target database. This ability to configure and initialize the database effectively improves the usability of the target database.
[0014] Optionally, the configuration parameters include: name information and configuration information; the configuration parameters for setting the initial database include:
[0015] Determine the name information of the initial database;
[0016] The configuration information of one or more of the initial data tables is determined; wherein the configuration information includes at least the following information: capacity parameters and storage cycle parameters for each initial data table.
[0017] In the above implementation process, during the basic configuration, the database name, capacity, and storage period of multiple initial data tables in the initial database can be configured to effectively configure the basic information of the database and the structure of the data tables.
[0018] Optionally, the step of querying whether there is a corresponding historical data table in all initial data tables of the target database according to the operation instructions of the target database includes:
[0019] Monitor the operation processing of the target database to obtain corresponding operation instructions;
[0020] Obtain the operation data corresponding to the operation instruction;
[0021] The operation data is matched with the configuration information corresponding to all the initial data tables to determine whether there is a corresponding historical data table.
[0022] In the above implementation process, to determine whether the target database already contains a data table corresponding to the operation instruction, the operation processing in the target database can be monitored first to identify the corresponding operation instruction and corresponding operation data. Then, the operation data is matched against the configuration information corresponding to all initial data tables to determine whether the target database already contains an initial data table as a historical data table corresponding to the operation processing. This allows for the initial data tables already existing in the target database to be searched and matched, and the corresponding data table processing method is determined based on the query results.
[0023] Optionally, creating a new data table in the target database based on the updated version number includes:
[0024] The updated version number and the initial version number are compared to monitor whether the version number of the target database has changed.
[0025] If a change in the version number of the target database is detected, the new data table is created in the target database based on the operation data corresponding to the operation instruction.
[0026] In the above implementation process, to monitor and detect changes in the version number of the target data, the updated version number and the initial version number of the target database can be compared. This allows for monitoring and processing of version number changes, enabling the creation of new data tables in the target database when a version number changes. By tracking version number changes, automatic table creation is achieved, eliminating the need for manual database access and effectively reducing operational costs and improving table creation efficiency.
[0027] Optionally, the method further includes:
[0028] If one or more of the historical data tables exist in the target database, the operation instruction is executed in any of the historical data tables.
[0029] In the above implementation process, if one or more historical data tables corresponding to the operation already exist in the target database, there is no need to create new data tables. Operation instructions can be executed directly in any historical data table to achieve the corresponding operation. Being able to execute corresponding operations directly in existing data tables, without creating new data tables each time, effectively reduces the cost of data table creation and improves the efficiency of operation processing.
[0030] Optionally, before determining the update version number based on the initial version number of the target database, the method further includes:
[0031] Monitor the current version number of the target database to obtain the initial version number of the target database;
[0032] The step of determining the update version number based on the initial version number of the target database includes:
[0033] The updated version number is obtained by incrementing the initial version number.
[0034] In the above implementation process, during the use of the target database, the current version number is continuously monitored and used as the initial version number of the target database. When a corresponding historical data table does not exist in the target database, the initial version number is incremented to obtain the corresponding updated version number, thus realizing the version number change function and dynamically creating data tables based on version number changes. The ability to continuously monitor and increment the version number effectively ensures the uniqueness of each version number, thereby improving the effectiveness of creating data tables based on version number changes.
[0035] Secondly, embodiments of this application also provide a database processing apparatus, the apparatus comprising: a query module, a determination module, and a creation module;
[0036] The query module is used to query whether there is a corresponding historical data table in all initial data tables of the target database according to the operation instructions of the target database.
[0037] If the query module finds that the historical data table does not exist in the target database, the determining module is used to determine the update version number based on the initial version number of the target database;
[0038] The creation module is used to create a new data table in the target database based on the updated version number.
[0039] In the above implementation process, the query module queries whether there is a corresponding historical data table based on the operation instructions of the target database. If there is no historical data table, the determination module processes the database in the form of an auto-incrementing version number to obtain the updated version number. The creation module listens for changes in the database version number and dynamically creates new data tables based on the updated version number when the version number changes.
[0040] Thirdly, embodiments of this application also provide an electronic device, which includes a memory and a processor. The memory stores program instructions, and when the processor reads and runs the program instructions, it executes the steps in any of the above-described implementations of the database processing method.
[0041] Fourthly, embodiments of this application also provide a computer-readable storage medium storing computer program instructions, which, when read and executed by a processor, perform steps in any of the above-described implementations of the database processing method.
[0042] In summary, the embodiments of this application provide a database processing method, apparatus, electronic device, and readable storage medium. By processing the database through an auto-incrementing version number, changes in the database version number are monitored and new data tables are added. This enables the dynamic creation of data tables during database use, effectively improving database operation efficiency, thereby reducing the operational cost of structured data caching, improving the efficiency of structured data caching, and meeting various user needs. Attached Figure Description
[0043] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0044] Figure 1 A block diagram illustrating an electronic device provided in an embodiment of this application;
[0045] Figure 2 A schematic flowchart illustrating a database processing method provided in an embodiment of this application;
[0046] Figure 3 A detailed flowchart of step S200 provided for an embodiment of this application;
[0047] Figure 4 A detailed flowchart of step S400 provided for an embodiment of this application;
[0048] Figure 5 This is a schematic diagram of the structure of a database processing device provided in an embodiment of this application.
[0049] Icons: 100 - Electronic device; 111 - Memory; 112 - Memory controller; 113 - Processor; 114 - Peripheral interface; 115 - Input / output unit; 116 - Display unit; 500 - Database processing device; 510 - Query module; 520 - Determine module; 530 - Creation module. Detailed Implementation
[0050] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of the embodiments of this application.
[0051] To reduce data loss or inability to troubleshoot issues caused by network or system anomalies, databases typically implement structured data caching. This allows for automatic data reporting, helping to prevent data loss and improve troubleshooting efficiency. IndexedDB is a commonly used database, but it only allows pre-setting table structures and cannot dynamically create tables and structures during use. When performing data caching or other processing, it requires calling a new IndexedDB instance to create new tables or structures, lacking visibility and limiting various database functions. Furthermore, the operation cost for structured data caching is high and the efficiency is low, failing to meet user needs.
[0052] To address the aforementioned issues, this application provides a database processing method applicable to electronic devices, such as servers, personal computers (PCs), tablets, smartphones, and personal digital assistants (PDAs) with logical computing capabilities. This method enables the automatic and dynamic creation of new data tables or table structures during the use of IndexedDB.
[0053] Optionally, please refer to Figure 1 , Figure 1 This is a block diagram illustrating an electronic device according to an embodiment of this application. The electronic device 100 may include a memory 111, a memory controller 112, a processor 113, a peripheral interface 114, an input / output unit 115, and a display unit 116. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device 100. For example, the electronic device 100 may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0054] The aforementioned memory 111, memory controller 112, processor 113, peripheral interface 114, input / output unit 115, and display unit 116 are electrically connected directly or indirectly to each other to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines. The aforementioned processor 113 is used to execute executable modules stored in the memory.
[0055] The memory 111 can be, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), etc. The memory 111 stores programs. After receiving execution instructions, the processor 113 executes the programs. The methods executed by the electronic device 100 as defined in any embodiment of this application can be applied to the processor 113, or implemented by the processor 113.
[0056] The aforementioned processor 113 may be an integrated circuit chip with signal processing capabilities. The processor 113 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a digital signal processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor.
[0057] The peripheral interface 114 described above couples various input / output devices to the processor 113 and the memory 111. In some embodiments, the peripheral interface 114, the processor 113, and the memory controller 112 can be implemented on a single chip. In other instances, they can be implemented on separate chips.
[0058] The input / output unit 115 described above is used to provide user input data. The input / output unit 115 can be, but is not limited to, a mouse and a keyboard.
[0059] The aforementioned display unit 116 provides an interactive interface (e.g., a user interface) between the electronic device 100 and the user, or displays image data for the user's reference. In this embodiment, the display unit can be a liquid crystal display (LCD) or a touch display. If it is a touch display, it can be a capacitive touchscreen or a resistive touchscreen that supports single-point and multi-point touch operations. Supporting single-point and multi-point touch operations means that the touch display can sense touch operations generated simultaneously from one or more locations on the touch display and pass the sensed touch operations to the processor for calculation and processing. In this embodiment, the display unit 116 can display existing and created data tables or table structures in the database.
[0060] The electronic device in this embodiment can be used to execute various steps in the database processing methods provided in the embodiments of this application. The implementation process of the database processing methods is described in detail below through several embodiments.
[0061] Please see Figure 2 , Figure 2 This is a flowchart illustrating a database processing method provided in an embodiment of this application. The method may include steps S200-S400.
[0062] Step S200: Based on the operation instructions of the target database, query whether there are corresponding historical data tables in all initial data tables of the target database.
[0063] The target database can be IndexedDB in a browser environment, which can be created and manipulated by web page scripts, allowing for the storage of large amounts of data, providing a lookup interface, and enabling indexing. Through an API, different entities are abstracted into object interfaces. By simulating a relational database using IndexedDB, and implementing SQL statements to achieve a sharded data structure, different data can be categorized and managed. Simulating backend database operations avoids frequent startups, reduces resource consumption, and improves user experience. When the network is poor or the system malfunctions, it can automatically report anomalies to prevent data loss and improve troubleshooting efficiency. Historical data tables can include data tables and their corresponding table structures.
[0064] It should be noted that the operation instructions can be commands that call class libraries to simulate various operations on the database. Since the corresponding data tables can be analyzed based on the operation instructions, and some initial data tables exist in the target database, a query can be performed in the target database based on the operation instructions to determine whether there are historical data tables corresponding to the operation instructions.
[0065] It should be noted that, in order to achieve the function of dynamically creating data tables in the target database, the target database can be determined in the following way: setting the configuration parameters of the initial database; and initializing the initial database according to the configuration parameters to obtain the target database. The initial database can be initialized and configured, and corresponding configuration parameters can be preset during configuration. The configuration parameters are cached using the built-in structure tables of the initial database, thereby achieving the initialization process and obtaining a usable target database. The ability to configure and initialize the database accordingly effectively improves the usability of the target database.
[0066] Optionally, configuration parameters may include: name information and configuration information; setting the configuration parameters of the initial database may include: determining the name information of the initial database; determining the configuration information of one or more initial data tables; wherein, the configuration information may include at least the following information: capacity parameters and storage period parameters for each initial data table. The name of the database and the capacity and storage period of multiple initial data tables within the initial database can be configured. For example, the name of the initial database can be named using a type, string, etc., and the storage capacity parameter of a certain initial data table can be set to 100MB, and the storage period parameter to 2 minutes, to limit the expiration period of data. Therefore, after the initial data table is full, some data that has existed in the storage table for more than 2 minutes can be deleted, so that new data can continue to be stored in the initial data table. This allows for effective configuration of the basic information of the database and the structure of the data tables.
[0067] Step S300: If the target database does not contain a historical data table, the update version number is determined based on the initial version number of the target database.
[0068] If the target database does not have a historical data table corresponding to the operation instruction, it indicates that a new data table needs to be created based on the operation instruction to implement the corresponding operation. Therefore, the function of dynamically creating data tables can be implemented based on the database version number.
[0069] Optionally, the initial version number is the version number of the current version of the target database, such as 1.0.0, and the updated version number can be the version number after incrementing the initial version number once or multiple times, such as 1.0.1, 1.0.2, etc.
[0070] It should be noted that before step S300, during the use of the target database, the current version number of the target database can be monitored to obtain the initial version number. Determining the update version number based on the initial version number of the target database can include: incrementing the initial version number to obtain the update version number. When there is no corresponding historical data table in the target database, the initial version number is incremented to obtain the corresponding update version number, thereby realizing the version number change function and dynamically creating data tables based on version number changes. The ability to continuously monitor and increment the version number effectively ensures the uniqueness of each version number, thus improving the effectiveness of creating data tables based on version number changes.
[0071] Step S400: Create a new data table in the target database based on the updated version number.
[0072] This feature allows monitoring of database version number changes and dynamically creating new data tables based on the updated version number when the version number changes.
[0073] exist Figure 2 In the illustrated embodiment, the function of dynamically creating data tables can be realized during the use of the database, which effectively improves the operational efficiency of the database, thereby reducing the operational cost of caching structured data, improving the efficiency of caching structured data, and meeting various user needs.
[0074] Optionally, please refer to Figure 3 , Figure 3 This is a detailed flowchart of step S200 provided in an embodiment of the present application. Step S200 may include steps S210-S230.
[0075] Step S210: Monitor the operation processing of the target database and obtain the corresponding operation instructions.
[0076] This includes the ability to monitor operations on the target database and extract corresponding operation instructions when such operations are detected.
[0077] Step S220: Obtain the operation data corresponding to the operation instruction.
[0078] For example, during the operation, SQL statements can be used to process the data to obtain the corresponding operation data. By parsing the SQL statements in the operation data, the corresponding query type, data table name, conditions, and output fields (such as product name, price, etc.) can be obtained. When performing a search, various search conditions can be used to traverse the data and filter it in the SQL statement to obtain the corresponding data table, pointer, and the result of pointer traversal of the output fields.
[0079] Step S230: Match the operation data with the configuration information corresponding to all initial data tables to determine whether there is a corresponding historical data table.
[0080] In this process, configuration information such as the table name, storage capacity, and storage period of the corresponding data table can be extracted from the operation data. Therefore, the configuration information of the data table corresponding to the operation data can be matched with the configuration information of the existing initial data table in the target database to determine whether there is an initial data table with the same configuration information as a historical data table.
[0081] It should be noted that if the target database contains one or more historical data tables, the operation instructions will be executed in any of these historical data tables. If the target database already contains one or more historical data tables corresponding to the operation, there is no need to create new data tables; the operation instructions can be executed directly in any of these historical data tables to achieve the corresponding operation. Being able to execute corresponding operations directly in existing data tables, without creating new data tables each time, effectively reduces the cost of creating data tables and improves the efficiency of operation processing.
[0082] It's important to note that after defining the historical data table or creating a new data table, various operations can be performed in either table to handle these operations, including adding, batch adding, querying by conditions, deleting, batch deleting, updating, and batch updating. Since both historical and new data tables have limitations on size and storage period, data can be intercepted before operations to check for expiration (automatic deletion if expired) and whether the intercepted data size exceeds or reaches the data cache limit. After exporting the data obtained from conditional queries, native JavaScript APIs can be used to export and download the data locally. Downloading uses HTTP upload requests, and to ensure proper data transmission, network status can be monitored. For example, native JavaScript APIs (navigator.connection and navigator.onLine) or heartbeat detection technology can be used to monitor network download speed, network changes and status, request latency, current network status, and connection status to improve data transmission efficiency. If the network conditions are good, you can call the business interface to upload untagged data. After uploading, you can tag the data or delete the data in the table to avoid uploading data repeatedly. After the operation is completed, you can call the IndexedDB API to manually close and delete the database connection.
[0083] exist Figure 3In the illustrated embodiment, the existing initial data tables in the target database can be searched and matched first, so as to determine the corresponding data table processing method based on the query results.
[0084] Optionally, please refer to Figure 4 , Figure 4 This is a detailed flowchart of step S400 provided in an embodiment of the present application. Step S400 may include steps S410-S420.
[0085] Step S410: Compare the monitored updated version number with the initial version number to monitor whether the version number of the target database has changed.
[0086] In order to monitor and detect changes in the version number of the target data, the updated version number and the initial version number of the target database can be compared to monitor and process the version number change.
[0087] Step S420: If a change in the version number of the target database is detected, a new data table is created in the target database based on the operation data corresponding to the operation instruction.
[0088] If the updated version number is different from the initial version number, it indicates that the version number of the target database has changed. When the version number changes, the corresponding configuration information can be extracted according to the operation data corresponding to the operation instruction. A new data table can be created in the target database according to parameters such as data table name, storage capacity and storage period. The new data table can also include data table and corresponding table structure data.
[0089] exist Figure 4 In the illustrated embodiment, the automatic creation of data tables can be achieved by changing the version number, eliminating the need to manually call a new database to create the corresponding data tables, effectively reducing operational costs and improving the efficiency of data table creation.
[0090] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of a database processing device provided in an embodiment of the present application. The database processing device 500 may include: a query module 510, a determination module 520, and a creation module 530.
[0091] The query module 510 is used to query whether there are corresponding historical data tables in all initial data tables of the target database according to the operation instructions of the target database.
[0092] If the query module finds that the historical data table does not exist in the target database, the determination module 520 is used to determine the update version number based on the initial version number of the target database;
[0093] Module 530 is used to create new data tables in the target database based on the updated version number.
[0094] In an optional embodiment, the database processing device 500 may further include a database configuration module for setting configuration parameters of the initial database; and performing initialization processing on the initial database according to the configuration parameters to obtain the target database.
[0095] In an optional implementation, the configuration parameters include: name information and configuration information; the database configuration module is specifically used to: determine the name information of the initial database; determine the configuration information of one or more initial data tables; wherein the configuration information includes at least the following information: capacity parameters and storage cycle parameters for each initial data table.
[0096] In an optional implementation, the query module 510 is specifically used to: monitor the operation processing of the target database to obtain the corresponding operation instructions; obtain the operation data corresponding to the operation instructions; and match the operation data with the configuration information corresponding to all initial data tables to determine whether there is a corresponding historical data table.
[0097] In an optional implementation, the creation module 530 is specifically used to: compare the monitored update version number with the initial version number to monitor whether the version number of the target database has changed; if the version number of the target database has changed, then create a new data table in the target database based on the operation data corresponding to the operation instruction.
[0098] In an optional implementation, if the query module 510 finds one or more historical data tables in the target database, it executes an operation instruction in any of the historical data tables.
[0099] In an optional implementation, the database processing device 500 may further include a listening module for listening to the current version number of the target database and obtaining the initial version number of the target database.
[0100] The module 520 is specifically used to: perform auto-incrementing processing based on the initial version number to obtain the updated version number.
[0101] Since the principle of the database processing device 500 in this embodiment is similar to that of the aforementioned database processing method, the implementation of the database processing device 500 in this embodiment can refer to the description in the above-mentioned database processing method embodiment, and repeated details will not be repeated.
[0102] This application also provides a computer-readable storage medium storing computer program instructions. When the computer program instructions are read and executed by a processor, they perform the steps of any of the methods in the database processing method provided in this embodiment.
[0103] In the several embodiments provided in this application, it should be understood that the disclosed device can also be implemented in other ways. The device embodiments described above are merely illustrative; for example, the block diagrams in the accompanying drawings illustrate the possible architecture, functions, and operations of the device according to various embodiments of this application. In this regard, each block in the block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram, and combinations of block diagrams, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0104] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0105] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0106] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application. It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0107] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
[0108] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.
Claims
1. A database processing method characterized by, The method comprises: According to the operation instruction of the target database, query whether there is a corresponding historical data table in all initial data tables of the target database; wherein the target database is an IndexedDB database; If the historical data table does not exist in the target database, determine the update version number according to the initial version number of the target database; Based on the update version number, create a new data table in the target database; According to the operation instruction of the target database, query whether there is a corresponding historical data table in all initial data tables of the target database, comprising: listening to the operation processing of the target database to obtain the corresponding operation instruction; obtain the operation data corresponding to the operation instruction; based on the operation data and the configuration information corresponding to all the initial data tables, to determine whether there is a corresponding historical data table; Before determining the update version number according to the initial version number of the target database, the method further comprises: listening to the current version number of the target database to obtain the initial version number of the target database; determining the update version number according to the initial version number, comprising: incrementing the initial version number to obtain the update version number.
2. The method of claim 1, wherein, Wherein, The target database is determined by the following way: Set the configuration parameters of the initial database; According to the configuration parameters, the initial database is initialized to obtain the target database.
3. The method of claim 2, wherein, Wherein, The configuration parameters include: name information and configuration information; setting the configuration parameters of the initial database, comprising: Determine the name information of the initial database; Determine the configuration information of one or more initial data tables; wherein the configuration information at least includes the following information: the capacity parameter and the storage period parameter of each initial data table.
4. The method of claim 1, wherein, Based on the update version number, create a new data table in the target database, comprising: Compare the update version number and the initial version number based on the listening to determine whether the version number of the target database has changed; If the version number of the target database is changed, create the new data table in the target database based on the operation data corresponding to the operation instruction.
5. The method according to any one of claims 1-4, characterized in that, The method further comprises: If one or more historical data tables exist in the target database, execute the operation instruction in any historical data table.
6. A database processing apparatus characterized by comprising: The device comprises a query module, a determination module and a creation module; The query module is used to query whether there is a corresponding historical data table in all initial data tables of the target database according to the operation instruction of the target database; wherein the target database is an IndexedDB database; If the query module queries that the historical data table does not exist in the target database, the determination module is used to determine the update version number according to the initial version number of the target database; The creation module is used to create a new data table in the target database based on the update version number; The query module is specifically configured to: listen to operation processing of the target database to obtain a corresponding operation instruction; acquire operation data corresponding to the operation instruction; and match the operation data with configuration information corresponding to all the initial data tables to determine whether there is a corresponding historical data table; The listening module is configured to listen to a current version number of the target database to obtain an initial version number of the target database; and the determining module is specifically configured to: perform self-increment processing according to the initial version number to obtain the updated version number.
7. An electronic device, comprising: The electronic device includes a memory and a processor, the memory stores program instructions, and the processor executes the program instructions to perform the steps in the method of any one of claims 1-5.
8. A computer readable storage medium, characterized in that, The readable storage medium stores computer program instructions, and the computer program instructions are executed by a processor to perform the steps in the method of any one of claims 1-5.
Citation Information
Patent Citations
Pattern management method and system of NoSQL database
CN103714163A
Halloween protection in a multi-version database system
US20120109903A1