@auramarker/latdb
v0.3.20
Published
一个基于文本的本地数据库。
Readme
LatDB
一个基于文本的本地数据库。
API
const db = new LatDB(save_path)Dict: 哈希表
db.dict.mydict.set('key', 1)set(key, value)get(key)keys()remove()update(obj)toJSON()clear()
List: 列表
db.list.mylist.push('abc')push(item)pop()lpush(item)lpop()rpush(item)rpop()extend(array)lextend(array)rextend(array)all()find(predicate)filter(predicate)map(predicate)index(index)indexOf(item)clear()remove()slice(start, end?)splice(start, delete_count, insert_items?)
Set: 集合
db.set.myset.add('abc')add(value)delete(value)has(value)all()remove()
Collection
增强版的 List,用于存储复杂数据,每项记录都是一个 document,包含 _id 等字段。
db.collection.mycollection.insert({
title: 'Title',
content: 'Content',
})insert(doc)delete(_id)update(_id, obj)all()find(predicate)filter(predicate)index(index)count()
