/fs-json-storage

Fs Json Storage

Primary LanguageJavaScript

fs-json-storage

Fs Json Storage

Use

1、npm i --save https://github.com/pashangshangpo/fs-json-storage.git

2、const Storage = require('fs-json-storage')

Demo

const Storage = require('fs-json-storage')
const storage = Storage('./storage.json')

Storage(storagePath)

储存类

Kind: global function

Param Type Description
storagePath String 文件路径

Storage~get(key) ⇒ Object | Array | Null

获取数据

Kind: inner method of Storage

Param Type Description
key String 键,可选,不写获取全部

Storage~set(...args)

替换键数据或添加数据,传递对象则覆盖整个数据

Kind: inner method of Storage

Param Type Description
...args any key,value

Storage~add(...args)

向数组添加数据

Kind: inner method of Storage

Param Type Description
...args any {}

Storage~remove(key)

删除指定键下的数据

Kind: inner method of Storage

Param Type Description
key String 键,可选,不写删除所有数据

Storage~empty()

清空数据

Kind: inner method of Storage

Storage~find(func) ⇒ Array

查找符合条件的数组数据

Kind: inner method of Storage
Returns: Array - Promise

Param Type Description
func function 过滤数据方法