Skip to content

cook-nested是一个针对嵌套结构数据提供 "新增,删除,更新,选择" 操作的库

Notifications You must be signed in to change notification settings

leonwens/cook-nested

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cook-nested

cook-nested 是一个针对嵌套结构数据提供 新增,删除,更新,选择操作的库

数据操作过程

image

使用方式

新增

import cookNestedData from 'cook-nested';
cookNestedData(originData, {
  type: 'INSERT',
  id: '2',
  data: {}
});

删除

import cookNestedData from 'cook-nested';
cookNestedData(originData, {
  type: 'DELETE',
  id: '1'
});

更新

import cookNestedData from 'cook-nested';
cookNestedData(originData, {
  type: 'UPDATE',
  id: '1',
  data: {}
});

选择

import cookNestedData from 'cook-nested';
cookNestedData(originData, {
  type: 'SELECT',
  id: '1'
});

多种操作

// 删掉id=1的元素然后在id=2的元素后插入新的data
import cookNestedData from 'cook-nested';
cookNestedData(
  originData,
  {
    type: 'DELETE',
    id: '1'
  },
  {
    type: 'INSERT',
    id: '2',
    data: {}
  }
);

About

cook-nested是一个针对嵌套结构数据提供 "新增,删除,更新,选择" 操作的库

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published