nv-id-info-local-db
v1.0.2
Published
nv-id-info-local-db ======================= - for small scale data (count < 1024 X 1024) local-storage
Downloads
6
Readme
nv-id-info-local-db
- for small scale data (count < 1024 X 1024) local-storage
install
- npm install nv-id-info-local-db
usage
const x = require("nv-id-info-local-db");
example
var db = x.creat_db("./TEST",1024,64);
/*
> db
DB {
meta: {
real_cnt: 1025,
max_cnt: 1024,
each_group_cnt: 64,
groups: [
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array]
]
},
pathd: {
workdir: '/home/cu-lib/nv-id-info-local-db/TEST',
meta: '/home/cu-lib/nv-id-info-local-db/TEST/___meta___.json',
zero: '/home/cu-lib/nv-id-info-local-db/TEST/0.v8ser',
groups: [
'/home/cu-lib/nv-id-info-local-db/TEST/g0',
'/home/cu-lib/nv-id-info-local-db/TEST/g1',
'/home/cu-lib/nv-id-info-local-db/TEST/g2',
'/home/cu-lib/nv-id-info-local-db/TEST/g3',
'/home/cu-lib/nv-id-info-local-db/TEST/g4',
'/home/cu-lib/nv-id-info-local-db/TEST/g5',
'/home/cu-lib/nv-id-info-local-db/TEST/g6',
'/home/cu-lib/nv-id-info-local-db/TEST/g7',
'/home/cu-lib/nv-id-info-local-db/TEST/g8',
'/home/cu-lib/nv-id-info-local-db/TEST/g9',
'/home/cu-lib/nv-id-info-local-db/TEST/g10',
'/home/cu-lib/nv-id-info-local-db/TEST/g11',
'/home/cu-lib/nv-id-info-local-db/TEST/g12',
'/home/cu-lib/nv-id-info-local-db/TEST/g13',
'/home/cu-lib/nv-id-info-local-db/TEST/g14',
'/home/cu-lib/nv-id-info-local-db/TEST/g15'
]
},
memd: {
'0': {},
'1': {},
'2': {},
'3': {},
'4': {},
'5': {},
'6': {},
'7': {},
'8': {},
'9': {},
'10': {},
'11': {},
'12': {},
'13': {},
'14': {},
'15': {},
___zero___: { id: 0, f64passwd: 0, data: null }
},
cursor: 1,
flags: [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
... 925 more items
]
}
*/
var [id,hint] = db.inst_one(new Set([11,22,"sss"]))
/*
> id
1
> hint
1713774482623.2795
>
*/
> db.get_one(id,hint)
{
id: 1,
f64passwd: 1713774781353.7732,
data: Set(3) { 11, 22, 'sss' }
}
> db.updt_one(id,hint,new Error("err-as-data"))
true
> db.get_one(id,hint)
{
id: 1,
f64passwd: 1713774781353.7732,
data: Error: err-as-data
at REPL35:1:21
at Script.runInThisContext (node:vm:122:12)
at REPLServer.defaultEval (node:repl:570:29)
at bound (node:domain:433:15)
at REPLServer.runBound [as eval] (node:domain:444:12)
at REPLServer.onLine (node:repl:900:10)
at REPLServer.emit (node:events:523:35)
at REPLServer.emit (node:domain:489:12)
at [_onLine] [as _onLine] (node:internal/readline/interface:415:12)
at [_line] [as _line] (node:internal/readline/interface:886:18)
}
>
db.dele_one(id,hint)
> db.has(id,hint)
false
>
var [id,hint] = db.inst_one(new Set([11,22,"sss"]))
var [id,hint] = db.inst_one(new Map())
var [id,hint] = db.inst_one(new Uint8Array(8))
var [id,hint] = db.inst_one("qqq")
> db.slct((id,hint,data)=>typeof(data)=="string")
[ { id: 4, f64passwd: 1713777224232.4827, data: 'qqq' } ]
METHODS
db._save db.aloc db.constructor db.dele_one db.get_one db.gid db.gpath db.has
db.has_f64passwd db.has_id db.inst_one db.slct db.updt_one db.zero_
db.cursor db.flags db.memd db.meta db.pathd
APIS
creat\_db(workdir, max\_count=1024768, chunk\_count=1024) chunk\_count means how many data saved in one file
LICENSE
- ISC