Fs Json Storage
1、npm i --save https://github.com/pashangshangpo/fs-json-storage.git
2、const Storage = require('fs-json-storage')
const Storage = require('fs-json-storage')
const storage = Storage('./storage.json')
储存类
Kind: global function
Param | Type | Description |
---|---|---|
storagePath | String |
文件路径 |
- Storage(storagePath)
- ~get(key) ⇒
Object
|Array
|Null
- ~set(...args)
- ~add(...args)
- ~remove(key)
- ~empty()
- ~find(func) ⇒
Array
- ~get(key) ⇒
获取数据
Kind: inner method of Storage
Param | Type | Description |
---|---|---|
key | String |
键,可选,不写获取全部 |
替换键数据或添加数据,传递对象则覆盖整个数据
Kind: inner method of Storage
Param | Type | Description |
---|---|---|
...args | any |
key,value |
向数组添加数据
Kind: inner method of Storage
Param | Type | Description |
---|---|---|
...args | any |
{} |
删除指定键下的数据
Kind: inner method of Storage
Param | Type | Description |
---|---|---|
key | String |
键,可选,不写删除所有数据 |
清空数据
Kind: inner method of Storage
查找符合条件的数组数据
Kind: inner method of Storage
Returns: Array
- Promise
Param | Type | Description |
---|---|---|
func | function |
过滤数据方法 |