0.0.0 • Published 4 years ago
ref-storage v0.0.0
name TBC
sync-db is used ref-db is used but should be similar
object-db? sync-object-db?
Persist key-ed objects with cross-platform Storage under synchronous operations (not async) with auto normalization and denormalization.
Supported Platforms
name is built on top of cross-platform Storage, hence it works on:
- Browser (using window.localStorage)
- Node.js (using node-localstorage)
How it works?
This package is inspired from ref-db. However, the loaded object is not proxied. Instead, the denormalization is happened aggressively.
Object pooling is applied to support (key-ed) objects with cyclic reference.
Usage
Details refer to the test spec
Create the Store (database)
import { createStore, GeneralObject, nextKey } from '[name]'
type Data = GeneralObject & {
id: string
}
const store = createStore<Data>({
path: 'data',
keyField: 'id', // default to _id
nestedSave: false, // optional
nextKey, // optional
quota: 2 * 1024**3 // default
})
Get/Set key-values
store.set('num', 42)
store.set('str', 'Alice')
store.set('user', '{}')
0.0.0
4 years ago