Skip to content

Staviro/Qwery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Qwery.js

Qwery.js is a JavaScript library that allows a developer to add, get and update JSON data in a structured way on local storage. Qwery.js was built to be a simple NoSQL storage system for developers to use. It utilizes a memory cache to manage data operations and persists the state to LocalStorage.


Information

  • Author: Joseph Morukhuladi
  • License: MIT
  • Year: 2026

Note: Do not use qwery.js to store sensitive user information.


Initialization Example

To start using Qwery, initialize the instance with a configuration object and call the asynchronous create() method to load the storage into memory.

const qwery = new Qwery({
	name: "myAppDatabase",
	log: true // Enables console logging for operations
})

qwery.create()

Usage Examples

The following examples demonstrate how to use the core functions based on the library test suite.

Adding Data

Add an object to a specific dataset. If the dataset does not exist, it is created automatically.

const user = {id: "user_1", name: "John Doe"}

await qwery.add({
	dataset: "users",
	data: user
})

Updating Data

Update existing records by matching a specific field and merging new data properties into the object.

await qwery.update({
	dataset: "profile",
	field: "id",
	value: 1,
	data: {status: "online"} // This merges into the existing record
})

Removing Data

Remove a specific record from a dataset based on a field value.

await qwery.remove({
	dataset: "tasks",
	predicate: (x) => x.id === "A1"
})

Public Functions

  • create(): Initializes the storage and primes the memory cache from LocalStorage.
  • json(): Returns the current state of the database from memory as an object.
  • add(properties): Adds a single data object to a specified dataset. Requires 'dataset' and 'data'.
  • get(properties): Retrieves data based on a filter function (predicate). Requires 'dataset' and 'predicate'.
  • update(properties): Updates a record by merging new data into a matching item. Requires 'dataset', 'field', 'value', and 'data'.
  • remove(properties): Deletes all matching records from a dataset. Requires 'dataset' and 'predicate'.
  • removeAll(datasetName): Deletes all records from a specific dataset.
  • count(datasetName): Returns the number of records currently in a dataset.
  • has(properties): Checks if a record exists using a predicate. Requires 'dataset' and 'predicate'.
  • truncate(): Clears all data across all datasets in the instance.
  • reset(): Deletes the storage key from LocalStorage and clears the memory cache.
  • uuid(): Generates a cryptographically secure UUID string.
  • datasetExists(name): Checks if a dataset with the given name exists in storage.

Links

About

Qwery is a JavaScript library that allows a developer to add, get and update JSON data in a structured way on local storage

Topics

Resources

License

Stars

Watchers

Forks

Contributors