Key-value pair storage method and device for front-end tree structure data

By constructing a dual-index key-value pair storage structure, efficient operation and memory optimization of front-end tree data are achieved, solving the problems of low storage efficiency and high memory consumption in existing technologies, and improving the operation performance of large data volume scenarios.

CN122173491APending Publication Date: 2026-06-09CHINA RAILWAY CLOUD NETWORK INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA RAILWAY CLOUD NETWORK INFORMATION TECH CO LTD
Filing Date
2026-02-28
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

In existing technologies, the storage efficiency of front-end tree structure data is low, memory consumption is high, and root node location is cumbersome, resulting in increased operation latency and memory leaks, making it unsuitable for large data volume scenarios.

Method used

A dual-index key-value pair storage structure is adopted, including a primary index and a root index. The primary index maps node information through the unique identifier of the node, and the root index stores the root node identifier, thereby achieving decoupling of parent and child node storage and fast root node location. The node operation complexity is O(1).

Benefits of technology

It significantly improves node operation efficiency, reduces memory usage, solves the problem of lag in front-end tree structures with large amounts of data, reduces memory usage by more than 40%, and simplifies root node location.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure SMS_1
    Figure SMS_1
  • Figure SMS_2
    Figure SMS_2
Patent Text Reader

Abstract

This invention discloses a key-value pair storage method for front-end tree structure data, specifically implemented according to the following steps: Step 1, constructing a dual-index key-value pair storage structure; Step 2, obtaining the original nested tree data from the front end, converting the original nested tree data into a dual-index key-value pair storage structure, and initializing it; Step 3, performing node operations on the dual-index key-value pair storage structure initialized in Step 2, realizing node search, addition, and deletion operations; Step 4, restoring the tree structure based on the dual-index key-value pair storage structure. This invention also discloses a key-value pair storage device for front-end tree structure data, solving the problems of low data storage efficiency, high memory consumption, and cumbersome root node location in existing technologies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of front-end data processing technology, specifically relating to a key-value pair storage method for front-end tree structure data, and also relating to a key-value pair storage device for front-end tree structure data. Background Technology

[0002] In front-end development, tree-structured data is widely used in scenarios such as organizational structure display, file directory management, and permission menu rendering. Traditional tree data storage methods often use nested array structures, where each node object contains its own attributes and an array of child nodes (children), and the tree relationship is expressed through hierarchical nesting.

[0003] However, existing nested array storage solutions have significant technical drawbacks: First, when searching, adding, deleting, or modifying any node, it is necessary to recursively traverse the entire tree to locate the target node, resulting in a time complexity of O(n). When the number of nodes exceeds 1000, the operation latency increases significantly, causing the front-end interface to lag and node operation efficiency to be low. Second, due to the strong coupling relationship between parent and child nodes in the nested structure, node objects are repeatedly referenced, resulting in redundant memory usage and a high risk of memory leaks. Furthermore, repeated rendering requires re-parsing the entire nested tree, further exacerbating performance degradation. Third, because locating the root node is cumbersome, it is necessary to traverse the entire nested array to filter for the root node (a node without a parent node), making it impossible to quickly obtain the top-level entry point of the tree structure, thus increasing development complexity.

[0004] Existing technologies use single-object key-value pairs to store nodes, with node ID as the key and node information as the value. This only achieves individual storage of nodes, does not optimize the root node lookup mechanism, and the relationship between parent and child nodes still relies on nested attributes. It fails to completely decouple the hierarchical relationship and cannot fundamentally solve the problems of operation efficiency and memory usage. It is not suitable for efficient processing of large-scale front-end tree-structured scenarios. Summary of the Invention

[0005] One objective of this invention is to provide a key-value pair storage method for front-end tree structure data, which solves the problems of low data storage efficiency, high memory consumption, and cumbersome root node location in the prior art.

[0006] Another object of the present invention is to provide a key-value pair storage device for front-end tree structure data.

[0007] The technical solution adopted in this invention is a key-value pair storage method for front-end tree structure data, which is implemented according to the following steps:

[0008] Step 1: Construct a dual-index key-value pair storage structure; Step 2: Obtain the original nested tree data from the front end, convert the original nested tree data from the front end into a dual-index key-value pair storage structure, and initialize it; Step 3: Perform node operations on the double-indexed key-value pair storage structure initialized in Step 2 to realize node lookup, addition, and deletion operations; Step 4: Restore the tree structure based on the dual-index key-value pair storage structure.

[0009] The invention is further characterized in that, In step 1, the dual-index key-value pair storage structure includes a primary index and a root index. The primary index is a node mapping table nodeMap, which uses the unique identifier nodeId of each tree node as the key and the node information object as the value. The node information object includes the node's own attributes, the parent node's unique identifier parentId, and the child node's unique identifier list childrenIds. It does not contain nested child node objects, thus achieving decoupling of parent and child node storage. The root index is a list of root node identifiers, rootIds, which stores the unique identifiers of all root nodes separately. The unique identifier of the parent node, parentId, is null or a preset empty value. The root node can be quickly located without traversing the main index.

[0010] Step 2 specifically involves obtaining the original nested tree data from the front end, traversing each node in the original nested tree data, converting each node into a node information object format, and storing it in the main index nodeMap; Each node information data format includes a node information object with a unique identifier nodeId as the key and a value that includes the unique identifier parentId of the parent node, a list of unique identifiers childrenIds of the child nodes, and its own attributes. During the conversion, if the node is the root node and has no parent node, the corresponding unique identifier nodeId is added to the root index root node identifier list rootIds; if the node has child nodes, the unique identifier nodeId of the child node is stored sequentially into the corresponding child node unique identifier list childrenIds, thus completing the conversion to a double-index key-value pair structure.

[0011] Step 3 specifically involves: When searching for a node, the corresponding node information object is obtained from the main index node mapping table nodeMap based on the unique identifier nodeId of the target node. The time complexity is O(1), achieving node search with O(1) complexity without recursive traversal. When adding a node, obtain the unique identifier nodeId of the node to be added, the unique identifier parentId of the parent node, its own attributes, and child node information. Store the node to be added in the main index node mapping table nodeMap. If the unique identifier parentId of the parent node is null, add it to the root index root node identifier list rootIds. If the unique identifier parentId of the parent node is not null, find the parent node, update the main index node mapping table nodeMap and the root index root node identifier list rootIds or the child node unique identifier list childrenIds corresponding to the parent node, and realize the node addition. When deleting a node, the node information is retrieved from the main index node mapping table nodeMap based on the unique identifier nodeId of the node to be deleted. All child nodes are recursively deleted by traversing the unique identifier list childrenIds. Then, the nodeId of the node to be deleted is removed from the unique identifier list childrenIds of the parent node. If it is the root node, it is removed from rootIds. Finally, the record of the node to be deleted is deleted from nodeMap. The process of recursively deleting all child nodes of the node to be deleted updates the main index node mapping table nodeMap and the unique identifier list childrenIds of the parent node or the root node identifier list rootIds of the root index, thus achieving node deletion.

[0012] Adding a node also includes verifying the uniqueness of the node's unique identifier, nodeId. If the unique identifier, nodeId, already exists in the main index node mapping table, nodeMap, an exception is thrown or the existing node information is overwritten.

[0013] Node deletion also includes validating the list of unique identifiers of the node's child nodes (childrenIds) before deleting the node. If child nodes exist, all child nodes are recursively deleted before deleting the current node.

[0014] Step 4 specifically involves starting from the root index root node identifier list rootIds, traversing the child node unique identifier list childrenIds of each root node, recursively associating child node information, generating a nested array structure adapted to the rendering of the front-end tree component, and restoring the entire tree or a specified subtree as needed.

[0015] Another technical solution adopted in this invention is a key-value pair storage device for front-end tree structure data, which implements a key-value pair storage method for front-end tree structure data, including a storage structure construction module, an initialization module, a node operation module, a structure restoration module, and a storage carrier.

[0016] The invention is further characterized in that the storage structure construction module is used for a dual-index key-value pair storage structure, which includes a primary index and a root index, defines the format of node information objects, and realizes the decoupling of parent and child node storage and independent management of the root node; the initialization module is used to receive the original nested tree data from the front end, traverse the nodes and convert them into a dual-index storage format, and complete the initial loading of the storage structure. The node operation module includes a search unit, an add unit, and a delete unit. The search unit is used to directly obtain the node information object from the main index nodeMap based on the nodeId, realizing an O(1) complexity search based on the nodeId. The add unit is used to update the dual-index storage structure based on the parentId of the node to be added, realizing the addition of associated parent and child nodes. The delete unit is used to recursively delete child nodes and update the dual-index storage structure, realizing the deletion operation of cascaded child nodes.

[0017] The structure restoration module is used to recursively generate nested array structures adapted to the rendering of the front-end tree component, starting from the root index rootIds. It recursively generates nested array structures from the double index structure to adapt to the rendering requirements of the front-end tree component. The storage carrier is used to store the main index nodeMap, the root index rootIds, and all node information objects. It is implemented based on the front-end memory and supports reactive data binding.

[0018] The beneficial effects of this invention are as follows: the key-value pair storage method for front-end tree structure data of this invention constructs a dual-index key-value pair storage structure, with the main index serving as the core storage carrier and the root index storing all root node IDs, quickly locating the top-level node, realizing efficient node operations, decoupling of hierarchical relationships, and rapid location of root nodes, improving the performance of front-end tree data processing, significantly improving operational efficiency, optimizing memory usage, and enabling rapid location of root nodes. It also has strong compatibility and high practicality. Detailed Implementation

[0019] The present invention will now be described in detail with reference to specific embodiments.

[0020] Example 1 The key-value pair storage method for front-end tree structure data of this invention is implemented according to the following steps: Step 1: Construct a dual-index key-value pair storage structure; Step 2: Obtain the original nested tree data from the front end, convert the original nested tree data from the front end into a dual-index key-value pair storage structure, and initialize it; Step 3: Perform node operations on the double-indexed key-value pair storage structure initialized in Step 2 to realize node lookup, addition, and deletion operations; Step 4: Restore the tree structure based on the dual-index key-value pair storage structure.

[0021] Example 2 The key-value pair storage method for front-end tree structure data of this invention is implemented according to the following steps: Step 1: Construct a dual-index key-value pair storage structure; The dual-index key-value pair storage structure includes a primary index and a root index. The primary index is a node mapping table nodeMap, with the unique identifier nodeId of each tree node as the key and the node information object as the value. The node information object includes the node's own attributes, the parent node's unique identifier parentId, and the child node's unique identifier list childrenIds. It does not contain nested child node objects, thus achieving decoupling of parent and child node storage. The root index is a list of root node identifiers, rootIds, which stores the unique identifiers of all root nodes separately. The unique identifier of the parent node, parentId, is null or a preset empty value. The root node can be quickly located without traversing the main index.

[0022] Step 2: Obtain the original nested tree data from the front end, convert the original nested tree data from the front end into a dual-index key-value pair storage structure, and initialize it; Step 3: Perform node operations on the double-indexed key-value pair storage structure initialized in Step 2 to realize node lookup, addition, and deletion operations; Step 4: Restore the tree structure based on the dual-index key-value pair storage structure.

[0023] Example 3 The key-value pair storage method for front-end tree structure data of this invention is implemented according to the following steps: Step 1: Construct a dual-index key-value pair storage structure; The dual-index key-value pair storage structure includes a primary index and a root index. The primary index is a node mapping table nodeMap, with the unique identifier nodeId of each tree node as the key and the node information object as the value. The node information object includes the node's own attributes, the parent node's unique identifier parentId, and the child node's unique identifier list childrenIds. It does not contain nested child node objects, thus achieving decoupling of parent and child node storage. The root index is a list of root node identifiers, rootIds, which stores the unique identifiers of all root nodes separately. The unique identifier of the parent node, parentId, is null or a preset empty value. The root node can be quickly located without traversing the main index.

[0024] The default value for null is null. The node's own attributes are the business attributes of the front-end tree data, including at least one of name, status, and permission identifier.

[0025] Step 2: Obtain the original nested tree data from the front end, convert the original nested tree data from the front end into a dual-index key-value pair storage structure, and initialize it; Step 2 specifically involves obtaining the original nested tree data from the front end, traversing each node in the original nested tree data, converting each node into a node information object format, and storing it in the main index nodeMap; Each node information data format includes a node information object with a unique identifier nodeId as the key and a value that includes the unique identifier parentId of the parent node, a list of unique identifiers childrenIds of the child nodes, and its own attributes. During the conversion, if the node is the root node and has no parent node, the corresponding unique identifier nodeId is added to the root index root node identifier list rootIds; if the node has child nodes, the unique identifier nodeId of the child node is stored sequentially into the corresponding child node unique identifier list childrenIds, thus completing the conversion to a double-index key-value pair structure.

[0026] Step 3: Perform node operations on the double-indexed key-value pair storage structure initialized in Step 2 to realize node lookup, addition, and deletion operations; Step 3 specifically involves: When searching for a node, the corresponding node information object is obtained from the main index node mapping table nodeMap based on the unique identifier nodeId of the target node. The time complexity is O(1), achieving node search with O(1) complexity without recursive traversal. When adding a node, obtain the unique identifier nodeId of the node to be added, the unique identifier parentId of the parent node, its own attributes, and child node information. Store the node to be added in the main index node mapping table nodeMap. If the unique identifier parentId of the parent node is null, add it to the root index root node identifier list rootIds. If the unique identifier parentId of the parent node is not null, find the parent node, update the main index node mapping table nodeMap and the root index root node identifier list rootIds or the child node unique identifier list childrenIds corresponding to the parent node, and realize the node addition. Adding a node also includes verifying the uniqueness of the node's unique identifier, nodeId. If the unique identifier, nodeId, already exists in the main index node mapping table, nodeMap, an exception is thrown or the existing node information is overwritten.

[0027] When deleting a node, the node information is retrieved from the main index node mapping table nodeMap based on the unique identifier nodeId of the node to be deleted. All child nodes are recursively deleted by traversing the unique identifier list childrenIds. Then, the nodeId of the node to be deleted is removed from the unique identifier list childrenIds of the parent node. If it is the root node, it is removed from rootIds. Finally, the record of the node to be deleted is deleted from nodeMap. The process of recursively deleting all child nodes of the node to be deleted updates the main index node mapping table nodeMap and the unique identifier list childrenIds of the parent node or the root node identifier list rootIds of the root index, thus achieving node deletion.

[0028] Node deletion also includes validating the list of unique identifiers of the node's child nodes (childrenIds) before deleting the node. If child nodes exist, all child nodes are recursively deleted before deleting the current node.

[0029] Step 4: Restore the tree structure based on the dual-index key-value pair storage structure.

[0030] Step 4 specifically involves starting from the root index root node identifier list rootIds, traversing the child node unique identifier list childrenIds of each root node, recursively associating child node information, generating a nested array structure adapted to the rendering of the front-end tree component, and restoring the entire tree or a specified subtree as needed.

[0031] Example 4 The key-value pair storage device for front-end tree structure data of the present invention includes a storage structure construction module, an initialization module, a node operation module, a structure restoration module, and a storage carrier.

[0032] The storage structure construction module is used for a dual-index key-value pair storage structure, which includes a primary index and a root index. It defines the format of node information objects and realizes the decoupling of parent and child node storage and independent management of the root node.

[0033] The initialization module receives the original nested tree data from the front end, traverses the nodes, converts them into a dual-index storage format, and completes the initial loading of the storage structure.

[0034] The node operation module includes a search unit, an add unit, and a delete unit. The search unit is used to directly obtain the node information object from the main index nodeMap based on the nodeId, realizing an O(1) complexity search based on the nodeId. The add unit is used to update the dual-index storage structure based on the parentId of the node to be added, realizing the addition of associated parent and child nodes. The delete unit is used to recursively delete child nodes and update the dual-index storage structure, realizing the deletion operation of cascaded child nodes.

[0035] The structure restoration module is used to recursively generate nested array structures adapted to the rendering of front-end tree components, starting from the root index rootIds. It recursively generates nested array structures from the double-index structure to adapt to the rendering requirements of front-end tree components.

[0036] The storage medium is used to store the main index nodeMap, the root index rootIds, and all node information objects. It is implemented based on front-end memory and supports reactive data binding.

[0037] This invention relates to a key-value pair storage device for front-end tree-structured data, comprising a storage structure construction module, an initialization module, a node operation module, a structure restoration module, and a storage carrier. Among these five functional modules, the storage carrier serves as the core data support, providing storage medium for the other modules. The storage structure construction module builds a dual-index storage architecture, laying the foundation for initialization and node operations. The initialization module receives raw data and relies on the storage structure construction module to complete format conversion. Both the node operation module and the structure restoration module operate based on the dual-index structure, respectively achieving efficient node operations and nested structure generation. These modules collaboratively cover the entire process of "storage construction - data initialization - operation - rendering adaptation," intuitively demonstrating the modular design concept of the device.

[0038] Example 5 This embodiment uses JavaScript as an example to implement a dual-index key-value pair storage method for front-end tree structure data. The specific implementation steps are as follows: Step 1: Construct a dual-index key-value pair storage structure; Step 2: Obtain the original nested tree data from the front end, convert the original nested tree data from the front end into a dual-index key-value pair storage structure, and initialize it; During initialization, the original nested tree data is converted into a dual-index storage structure, with the parent node ID and the root node initialized to null. Construct a node information object with no nested children, associate child nodes with childrenIds, add the root index rootIds when processing the root node, and add the current node ID to the childIds of the parent node when processing a non-root node, and recursively process child nodes.

[0039] Step 3: Perform node operations on the double-indexed key-value pair storage structure initialized in Step 2 to realize node lookup, addition, and deletion operations; When searching for a node, the node information is obtained in O(1) complexity by using the target node ID and the node information object; When adding a node, associate the parent and child nodes, update the index, and the node to be added must contain an id and a parentId. The node to be added must contain a unique identifier id and a parent node identifier parentId. Store the node information. By default, childrenIds is an empty array. When the root node is added, update the root index. When a non-root node is added, update the parent node’s childrenIds.

[0040] When a node is deleted, child nodes are deleted in a cascading manner, the index is updated, all child nodes are recursively deleted based on the ID of the node to be deleted, the current node ID is removed from the parent node / root index, and the node is deleted from the primary index.

[0041] Step 4: Restore the tree structure based on the dual-index key-value pair storage structure.

[0042] Convert the dual-index structure into a nested array to adapt to front-end component rendering. The parent node ID list, the default root node, the nested tree data, and the child node nested structure are generated recursively.

[0043] This invention discloses a dual-index key-value pair storage method for front-end tree structure data. The method presents four core steps in sequence: First, constructing a dual-index key-value pair storage structure to lay the foundation for efficient storage; second, receiving the original nested data and completing the storage structure initialization to achieve data format conversion; next, performing efficient operations such as node search, addition, and deletion based on the dual-index structure; and finally, an optional tree structure restoration step to generate nested data adapted to front-end components.

[0044] The dual-index key-value pair storage structure constructed in this embodiment is shown in Table 1; Table 1 shows the constructed dual-index key-value pair storage structure.

[0045] Table 1 shows the structure of the core main index nodeMap at the top. The label key is the node's unique identifier nodeId, and the value is the node information object. The node information object clearly contains three core fields: its own attributes, parentId, and childrenIds. There are no nested child node objects. The bottom shows the structure of the root index rootIds, which is used to store all root nodeIds where parentId is null. It also marks the relationship between the main index and the root index, intuitively demonstrating the core design of decoupling parent and child nodes through ID storage and independent management of root nodes, reflecting the complete link of this invention from data storage to application rendering.

[0046] Example 6 Based on Example 5, this example compares the performance of the dual-index key-value pair storage method for front-end tree structure data with that of the traditional nested array storage scheme. The results are shown in Table 2. Table 2 shows the performance comparison between the present invention and the traditional nested array storage scheme.

[0047] Table 2 uses the number of nodes as the horizontal axis (covering five gradients: 100, 500, 1000, 2000, and 5000) and the average time taken for a single node operation (search, add, delete) as the vertical axis, with the unit being milliseconds. As shown in Table 1, with the increase in the number of nodes, the time taken by the traditional nested array scheme increases linearly, conforming to O(n) complexity, while the time taken by the scheme of this invention remains basically stable, conforming to O(1) complexity. When the number of nodes is ≥1000, the operation time of the scheme of this invention is reduced by more than 80% compared to the traditional scheme, directly demonstrating the significant advantage of this invention in improving the efficiency of large-scale tree data operations.

[0048] This invention provides a key-value pair storage method for front-end tree structure data. It achieves O(1) complexity for node lookup, addition, and deletion through the main index `nodeMap`. Compared to the O(n) complexity of traditional nested arrays, this method reduces operation time by over 80% when the number of nodes is ≥1000, completely solving the problem of lag in large-scale tree data operations and significantly improving operational efficiency. Parent and child nodes are associated by ID rather than nested object references, completely decoupling hierarchical storage dependencies and reducing memory redundancy caused by repeated references. Testing shows that memory usage is reduced by over 40% for the same number of nodes, reducing the risk of front-end memory leaks. Memory usage optimization: Root nodes are maintained separately using `rootIds`, eliminating the need to traverse the entire tree for filtering, greatly simplifying the root node acquisition process, improving tree structure initialization and rendering efficiency, and quickly locating root nodes. It is directly integrated into mainstream front-end frameworks such as Vue, React, and Angular without modifying the framework's native mechanisms, adapting to various front-end tree scenarios such as organizational structures, file directories, and permission menus. It boasts low development and integration costs, strong compatibility, and high practicality.

Claims

1. A key-value pair storage method for front-end tree structure data, characterized in that, The specific steps are as follows: Step 1: Construct a dual-index key-value pair storage structure; Step 2: Obtain the original nested tree data from the front end, convert the original nested tree data from the front end into a dual-index key-value pair storage structure, and initialize it; Step 3: Perform node operations on the double-indexed key-value pair storage structure initialized in Step 2 to realize node lookup, addition, and deletion operations; Step 4: Restore the tree structure based on the dual-index key-value pair storage structure.

2. The key-value pair storage method for front-end tree structure data according to claim 1, characterized in that, In step 1, the dual-index key-value pair storage structure includes a primary index and a root index. The primary index is a node mapping table nodeMap, which uses the unique identifier nodeId of each tree node as the key and the node information object as the value. The node information object includes the node's own attributes, the parent node's unique identifier parentId, and the child node's unique identifier list childrenIds. It does not contain nested child node objects, thus achieving decoupling of parent and child node storage. The root index is a list of root node identifiers, rootIds, which stores the unique identifiers of all root nodes separately. The unique identifier of the parent node, parentId, is null or a preset empty value. The root node can be quickly located without traversing the main index.

3. The key-value pair storage method for front-end tree structure data according to claim 2, characterized in that, Step 2 specifically involves obtaining the original nested tree data from the front end, traversing each node in the original nested tree data, converting each node into a node information object format, and storing it in the main index nodeMap; Each node information data format includes a node information object with a unique identifier nodeId as the key and a value that includes the unique identifier parentId of the parent node, a list of unique identifiers childrenIds of the child nodes, and its own attributes. During the conversion, if the node is the root node and has no parent node, the corresponding unique identifier nodeId is added to the root index root node identifier list rootIds; if the node has child nodes, the unique identifier nodeId of the child node is stored sequentially into the corresponding child node unique identifier list childrenIds, thus completing the conversion to a double-index key-value pair structure.

4. The key-value pair storage method for front-end tree structure data according to claim 3, characterized in that, Step 3 specifically involves: When searching for a node, the corresponding node information object is obtained from the main index node mapping table nodeMap based on the unique identifier nodeId of the target node. The time complexity is O(1), achieving node search with O(1) complexity without recursive traversal. When adding a node, obtain the unique identifier nodeId of the node to be added, the unique identifier parentId of the parent node, its own attributes, and child node information. Store the node to be added in the main index node mapping table nodeMap. If the unique identifier parentId of the parent node is null, add it to the root index root node identifier list rootIds. If the unique identifier parentId of the parent node is not null, find the parent node, update the main index node mapping table nodeMap and the root index root node identifier list rootIds or the child node unique identifier list childrenIds corresponding to the parent node, and realize the node addition. When deleting a node, the node information is retrieved from the main index node mapping table nodeMap based on the unique identifier nodeId of the node to be deleted. All child nodes are recursively deleted by traversing the unique identifier list childrenIds. Then, the nodeId of the node to be deleted is removed from the unique identifier list childrenIds of the parent node. If it is the root node, it is removed from rootIds. Finally, the record of the node to be deleted is deleted from nodeMap. The process of recursively deleting all child nodes of the node to be deleted updates the main index node mapping table nodeMap and the unique identifier list childrenIds of the parent node or the root node identifier list rootIds of the root index, thus achieving node deletion.

5. The key-value pair storage method for front-end tree structure data according to claim 4, characterized in that, Adding a node also includes verifying the uniqueness of the node's unique identifier, nodeId. If the unique identifier, nodeId, already exists in the main index node mapping table, nodeMap, an exception is thrown or the existing node information is overwritten.

6. The key-value pair storage method for front-end tree structure data according to claim 5, characterized in that, Node deletion also includes validating the list of unique identifiers of the node's child nodes (childrenIds) before deleting the node. If child nodes exist, all child nodes are recursively deleted before deleting the current node.

7. The key-value pair storage method for front-end tree structure data according to claim 6, characterized in that, Step 4 specifically involves starting from the root index root node identifier list rootIds, traversing the child node unique identifier list childrenIds of each root node, recursively associating child node information, generating a nested array structure adapted to the rendering of the front-end tree component, and restoring the entire tree or a specified subtree as needed.

8. A key-value pair storage device for front-end tree structure data, characterized in that, The key-value pair storage method for front-end tree structure data as described in claim 7 includes a storage structure construction module, an initialization module, a node operation module, a structure restoration module, and a storage carrier.

9. The key-value pair storage device for front-end tree structure data according to claim 8, characterized in that, The storage structure construction module is used for the dual-index key-value pair storage structure, which includes a primary index and a root index. It defines the format of node information objects, realizes the decoupling of parent and child node storage, and separate management of the root node. The initialization module is used to receive the original nested tree data from the front end, traverse the nodes and convert them into the dual-index storage format, and complete the initial loading of the storage structure. The node operation module includes a search unit, an add unit, and a delete unit. The search unit is used to directly obtain node information objects from the main index nodeMap based on nodeId, realizing O(1) complexity search based on nodeId. The addition unit is used to update the dual-index storage structure based on the parentId of the node to be added, so as to add related parent and child nodes; The deletion unit is used to recursively delete child nodes and update the dual-index storage structure, thus realizing the deletion operation of cascading child nodes.

10. The key-value pair storage device for front-end tree structure data according to claim 9, characterized in that, The structure restoration module is used to recursively generate nested array structures adapted to the rendering of the front-end tree component, starting from the root index rootIds. It recursively generates nested array structures from the double-index structure to adapt to the rendering requirements of the front-end tree component. The storage medium is used to store the main index nodeMap, the root index rootIds, and all node information objects. It is implemented based on front-end memory and supports reactive data binding.