Simple NoSQL storage for Local Storage.

A lightweight JavaScript library to add, get, and update JSON data in a structured way using a memory cache with persistence.

Get Started GitHub

Structured Data

Manage your JSON objects using datasets, keeping your local storage organized and queryable.

Memory Cache

Utilizes internal memory for lightning-fast read operations before syncing to persistent storage.

Async Ready

Built for modern workflows with full Promise support and clean asynchronous APIs.

Documentation

1. Initialize create()

Initialize your Qwery instance. This sets up the initial store in LocalStorage if it doesn't exist.

const qwery = new Qwery({ name: "my_app_db" });
await qwery.create();

// Output: The instance itself (chainable)

2. Add Data add()

Push a new object into a specific dataset.

await qwery.add({
    dataset: "users",
    data: { id: "u1", name: "John Doe", email: "john@example.com" }
});

// Output: Promise<void>

3. Retrieve Data get()

Fetch items based on a predicate function. Returns a single object if one match is found, or an array for multiple.

const user = await qwery.get({
    dataset: "users",
    predicate: (x) => x.id === "u1"
});

// Output: { id: "u1", name: "John Doe", ... }

4. Update Data update()

Merge new values into an existing record identified by a field/value pair.

await qwery.update({
    dataset: "users",
    field: "id",
    value: "u1",
    data: { name: "Johnny" }
});

// Output: Promise<void>

5. Remove Data remove()

Delete an item from a dataset.

await qwery.remove({
    dataset: "users",
    field: "id",
    value: "u1"
});

6. List Datasets listDatasets()

Get an array of all available dataset names in the instance.

const sets = qwery.listDatasets();
// Output: ["users", "settings", "posts"]

API Reference

A complete list of methods available on the Qwery instance.

uuid()

Generates a standard v4 UUID for unique record IDs.

count(dataset)

Returns the number of items in a specified dataset.

has(options)

Checks if a specific value exists in a dataset field. Returns boolean.

truncate()

Clears all datasets but preserves the database structure.

reset()

Deletes the database from LocalStorage entirely.

json()

Returns the raw object state of the entire database.