
Product
Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
@goldnet/localdb
Advanced tools
不限制大小的本地存储库
number, string, json, blob, arraybuffer
npm i @goldnet/localdb
import { LocalDB } from ' @goldnet/localdb';
// 建立全局的存储库
const localDB = getLocalDB();
await localDB.open(1);
async function load() {
// 相关模块使用
const key = 'key1';
let data = await localDB.get(key);
if (!data) {
console.log('存储');
const res = await fetch('/colors.png', {
"headers": {
responseType: 'arraybuffer'
}
});
const arraybuffer = await res.arrayBuffer();
await localDB.put({ md5: '1', data: arraybuffer }, key);
} else {
console.log('读取');
data = data.data;
}
console.log(data);
}
load();
const localDB = getLocalDB();
const localDB = new LocalDB(dbname);
需要添加数据库名,自定义 需要添加表明,自定义 版本号,默认1, 如果修改表或数据结构,版本号必须递增 在调用open方法之前,需要配置结构
localDB.configStoreObject([
{
name: tableName,
options: {
autoIncrement: true
}
}
]);
await localDB.open(version);
version 如果不传,默认版本号为1.
const result = await localDB.put(value,id);
value 要存储的数据,可以是 number, string, json, blob, arraybuffer id,用于查找的键值,如果没传入,会返回递增键值, 如果传入一个已经存在的,会更新数据 result 如果为 undefined, 数据库可能关闭、写入失败
const result = await localDB.get(id);
const result = await localDB.version();
只有版本变更才会更新 localDB.configStoreObject 中的数据结构,在每次版本变更需要考虑之前的结构,或调用删除方法
const result = await localDB.delete(id);
如果没有返回值,删除成功
await localDB.clear();
FAQs
The npm package @goldnet/localdb receives a total of 3 weekly downloads. As such, @goldnet/localdb popularity was classified as not popular.
We found that @goldnet/localdb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.