Dexie.js alternatives and similar libraries
Based on the "Storage" category.
Alternatively, view Dexie.js alternatives based on common mentions on social networks and blogs.
-
localForage
๐พ Offline storage, improved. Wraps IndexedDB, WebSQL, or localStorage using a simple but powerful API. -
js-cookie
A simple, lightweight JavaScript API for handling browser cookies -
jquery-cookie
A simple, lightweight jQuery plugin for reading, writing and deleting cookies. -
store.js
Cross-browser storage for all use cases, used across the web. -
NeDB
The JavaScript Database, for Node.js, nw.js, electron and the browser -
WatermelonDB
๐ Reactive & asynchronous database for powerful React and React Native apps โก๏ธ -
Lovefield
Lovefield is a relational database for web apps. Written in JavaScript, works cross-browser. Provides SQL-like APIs that are fast, safe, and easy to use. -
basket.js
A script and resource loader for caching & loading files with localStorage -
cookies.js
๐ซ Tastier cookies, local, session, and db storage in a tiny package. Includes subscribe() events for changes. -
jStorage
jStorage is a simple key/value database to store data on browser side -
DB.js
db.js is a wrapper for IndexedDB to make it easier to work against -
Hadmean
Generate powerful admin apps in seconds with just `npx hadmean`. Stop building and maintaining admin apps that you can auto-generate. -
awesome-web-storage
:sunglasses: Everything you need to know about Client-side Storage. -
datavore
A small, fast, in-browser database engine written in JavaScript. -
proxy-web-storage
Stokado is a library that serves as a syntax sugar for storage, providing support for serialization, subscription-based listening, expiration setting, and one-time value. -
crumbsjs
A lightweight vanilla ES6 cookies and local storage JavaScript library -
JSON ODM
A JSON ODM (object document mapper) for JavaScript to use on the server or in the browser.
AWS Cloud-aware infrastructure-from-code toolbox [NEW]
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Dexie.js or a related project?
README
Dexie.js
Dexie.js is a wrapper library for indexedDB - the standard database in the browser. https://dexie.org
Why?
Dexie solves three main issues with the native IndexedDB API:
- Ambiguous error handling
- Poor queries
- Code complexity
Dexie provides a neat database API with a well thought-through API design, robust error handling, extendability, change tracking awareness and extended KeyRange support (case insensitive search, set matches and OR operations).
Hello World
<!doctype html>
<html>
<head>
<script src="https://unpkg.com/[email protected]/dist/dexie.js"></script>
<script>
//
// Declare Database
//
var db = new Dexie("FriendDatabase");
db.version(1).stores({
friends: "++id,name,age"
});
//
// Manipulate and Query Database
//
db.friends.add({name: "Josephine", age: 21}).then(function() {
return db.friends.where("age").below(25).toArray();
}).then(function (youngFriends) {
alert ("My young friends: " + JSON.stringify(youngFriends));
}).catch(function (e) {
alert ("Error: " + (e.stack || e));
});
</script>
</head>
</html>
Yes, it's that simple.
An equivalent modern version (works in all modern browsers):
<!doctype html>
<html>
<head>
<script type="module">
import Dexie from "https://unpkg.com/[email protected]/dist/modern/dexie.mjs";
//
// Declare Database
//
const db = new Dexie("FriendDatabase");
db.version(1).stores({
friends: "++id,name,age"
});
//
// Manipulate and Query Database
//
try {
await db.friends.add({name: "Josephine", age: 21});
const youngFriends = await db.friends.where("age").below(25).toArray();
alert (`My young friends: ${JSON.stringify(youngFriends)}`);
} catch (e) {
alert (`Error: ${e}`);
}
</script>
</head>
</html>
Performance
Dexie has kick-ass performance. Its bulk methods take advantage of a lesser-known feature in IndexedDB that makes it possible to store stuff without listening to every onsuccess event. This speeds up the performance to a maximum.
Supported operations
above(key): Collection;
aboveOrEqual(key): Collection;
add(item, key?): Promise;
and(filter: (x) => boolean): Collection;
anyOf(keys[]): Collection;
anyOfIgnoreCase(keys: string[]): Collection;
below(key): Collection;
belowOrEqual(key): Collection;
between(lower, upper, includeLower?, includeUpper?): Collection;
bulkAdd(items: Array): Promise;
bulkDelete(keys: Array): Promise;
bulkPut(items: Array): Promise;
clear(): Promise;
count(): Promise;
delete(key): Promise;
distinct(): Collection;
each(callback: (obj) => any): Promise;
eachKey(callback: (key) => any): Promise;
eachPrimaryKey(callback: (key) => any): Promise;
eachUniqueKey(callback: (key) => any): Promise;
equals(key): Collection;
equalsIgnoreCase(key): Collection;
filter(fn: (obj) => boolean): Collection;
first(): Promise;
get(key): Promise;
inAnyRange(ranges): Collection;
keys(): Promise;
last(): Promise;
limit(n: number): Collection;
modify(changeCallback: (obj: T, ctx:{value: T}) => void): Promise;
modify(changes: { [keyPath: string]: any } ): Promise;
noneOf(keys: Array): Collection;
notEqual(key): Collection;
offset(n: number): Collection;
or(indexOrPrimayKey: string): WhereClause;
orderBy(index: string): Collection;
primaryKeys(): Promise;
put(item: T, key?: Key): Promise;
reverse(): Collection;
sortBy(keyPath: string): Promise;
startsWith(key: string): Collection;
startsWithAnyOf(prefixes: string[]): Collection;
startsWithAnyOfIgnoreCase(prefixes: string[]): Collection;
startsWithIgnoreCase(key: string): Collection;
toArray(): Promise;
toCollection(): Collection;
uniqueKeys(): Promise;
until(filter: (value) => boolean, includeStopEntry?: boolean): Collection;
update(key: Key, changes: { [keyPath: string]: any }): Promise;
This is a mix of methods from WhereClause, Table and Collection. Dive into the API reference to see the details.
Hello World (Typescript)
import Dexie, { Table } from 'dexie';
interface Friend {
id?: number;
name?: string;
age?: number;
}
//
// Declare Database
//
class FriendDatabase extends Dexie {
public friends!: Table<Friend, number>; // id is number in this case
public constructor() {
super("FriendDatabase");
this.version(1).stores({
friends: "++id,name,age"
});
}
}
const db = new FriendDatabase();
db.transaction('rw', db.friends, async() => {
// Make sure we have something in DB:
if ((await db.friends.where({name: 'Josephine'}).count()) === 0) {
const id = await db.friends.add({name: "Josephine", age: 21});
alert (`Addded friend with id ${id}`);
}
// Query:
const youngFriends = await db.friends.where("age").below(25).toArray();
// Show result:
alert ("My young friends: " + JSON.stringify(youngFriends));
}).catch(e => {
alert(e.stack || e);
});
Samples
https://dexie.org/docs/Samples
https://github.com/dexie/Dexie.js/tree/master/samples
Knowledge Base
https://dexie.org/docs/Questions-and-Answers
Website
Install over npm
npm install dexie
Download
For those who don't like package managers, here's the download links:
Legacy:
https://unpkg.com/[email protected]/dist/dexie.min.js
https://unpkg.com/[email protected]/dist/dexie.min.js.map
Modern:
https://unpkg.com/[email protected]/dist/modern/dexie.min.mjs
https://unpkg.com/[email protected]/dist/modern/dexie.min.mjs.map
Typings:
https://unpkg.com/[email protected]/dist/dexie.d.ts
Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md)
Build
pnpm install
pnpm run build
Test
pnpm test
Watch
pnpm run watch