Run OxiDB entirely in the browser. No server needed — all data lives in memory within the WASM module. Supports JSON queries, SQL, aggregation, and indexes.
Download the pre-built WASM package from GitHub releases and extract into your project:
curl -L -o oxidb-wasm.tar.gz \
https://github.com/parisxmas/OxiDB/releases/download/v0.28.18/oxidb-wasm-v0.28.18.tar.gz
mkdir wasm && tar xzf oxidb-wasm.tar.gz -C wasm/
Your project structure:
your-project/
wasm/
oxidb_wasm.js # ES module entry point
oxidb_wasm.d.ts # TypeScript types
oxidb_wasm_bg.wasm # WASM binary (~1.5 MB gzipped)
oxidb_wasm_bg.wasm.d.ts
index.html
Note: WASM files must be served from your own web server (same origin). Direct import from GitHub URLs will not work due to CORS restrictions.
Load the WASM module and create an in-memory database:
<script type="module">
import init, * as oxidb from './wasm/oxidb_wasm.js';
await init(); // load WASM binary
oxidb.init(); // create in-memory database
// ready to use
</script>
// Single document — returns document ID
const id = oxidb.insert('users', JSON.stringify({
name: 'Alice', age: 30, city: 'Berlin'
}));
// Multiple documents — returns JSON array of IDs
const ids = JSON.parse(oxidb.insert_many('users', JSON.stringify([
{ name: 'Bob', age: 25, city: 'Tokyo' },
{ name: 'Charlie', age: 35, city: 'Berlin' }
])));
// All documents
const all = JSON.parse(oxidb.find('users', '{}'));
// Filter
const berliners = JSON.parse(oxidb.find('users',
JSON.stringify({ city: 'Berlin' })
));
// Operators: $gt, $gte, $lt, $lte, $ne, $in, $nin, $exists, $regex
const older = JSON.parse(oxidb.find('users',
JSON.stringify({ age: { $gt: 25 } })
));
// Single document
const alice = JSON.parse(oxidb.find_one('users',
JSON.stringify({ name: 'Alice' })
));
// Returns number of modified documents
const n = oxidb.update('users',
JSON.stringify({ name: 'Alice' }), // filter
JSON.stringify({ $set: { age: 31 } }) // update
);
// Operators: $set, $unset, $inc, $mul, $min, $max, $push, $pull, $addToSet
oxidb.update('users',
JSON.stringify({ city: 'Berlin' }),
JSON.stringify({ $inc: { age: 1 } })
);
// Returns number of deleted documents
const n = oxidb.delete('users',
JSON.stringify({ age: { $lt: 20 } })
);
const total = oxidb.count('users', '{}');
const berliners = oxidb.count('users',
JSON.stringify({ city: 'Berlin' })
);
Full SQL support — same dialect as native OxiDB:
// SELECT
const result = JSON.parse(oxidb.sql(
'SELECT name, age FROM users WHERE age > 25 ORDER BY age'
));
console.log(result.rows);
// INSERT
oxidb.sql("INSERT INTO products (name, price) VALUES ('Laptop', 999)");
// UPDATE
oxidb.sql("UPDATE users SET age = age + 1 WHERE city = 'Berlin'");
// DELETE
oxidb.sql("DELETE FROM users WHERE age < 20");
// GROUP BY
const stats = JSON.parse(oxidb.sql(
'SELECT city, COUNT(*) as n, AVG(age) as avg_age FROM users GROUP BY city'
));
oxidb.create_index('users', 'age');
oxidb.create_index('users', 'city');
const pipeline = JSON.stringify([
{ $match: { age: { $gte: 20 } } },
{ $group: {
_id: '$city',
count: { $sum: 1 },
avg_age: { $avg: '$age' }
}},
{ $sort: { count: -1 } }
]);
const stats = JSON.parse(oxidb.aggregate('users', pipeline));
const names = JSON.parse(oxidb.list_collections());
oxidb.drop_collection('old_data');
<!DOCTYPE html>
<html>
<head><title>OxiDB WASM</title></head>
<body>
<pre id="out"></pre>
<script type="module">
import init, * as oxidb from './wasm/oxidb_wasm.js';
await init();
oxidb.init();
// Insert
oxidb.insert('tasks', JSON.stringify(
{ title: 'Buy groceries', done: false, priority: 'high' }
));
oxidb.insert('tasks', JSON.stringify(
{ title: 'Write docs', done: true, priority: 'medium' }
));
// Index
oxidb.create_index('tasks', 'priority');
// JSON query
const urgent = JSON.parse(oxidb.find('tasks',
JSON.stringify({ priority: 'high', done: false })
));
// SQL query
const result = JSON.parse(oxidb.sql(
"SELECT priority, COUNT(*) as n FROM tasks GROUP BY priority"
));
// Aggregation
const stats = JSON.parse(oxidb.aggregate('tasks', JSON.stringify([
{ $group: { _id: '$done', count: { $sum: 1 } } }
])));
document.getElementById('out').textContent =
JSON.stringify({ urgent, sql: result.rows, stats }, null, 2);
</script>
</body>
</html>
| Function | Arguments | Returns |
|---|---|---|
init() | — | Creates in-memory database |
insert(collection, jsonStr) | collection name, JSON document string | Document ID (string) |
insert_many(collection, jsonStr) | collection name, JSON array string | JSON array of IDs |
find(collection, queryStr) | collection name, JSON query string | JSON array string |
find_one(collection, queryStr) | collection name, JSON query string | JSON string or "null" |
update(collection, queryStr, updateStr) | filter, update operations | Modified count (number) |
delete(collection, queryStr) | collection name, JSON query string | Deleted count (number) |
count(collection, queryStr) | collection name, JSON query string | Count (number) |
sql(queryStr) | SQL query string | JSON result string |
aggregate(collection, pipelineStr) | collection name, JSON pipeline string | JSON array string |
create_index(collection, field) | collection name, field name | — |
list_collections() | — | JSON array of names |
drop_collection(name) | collection name | — |
# Prerequisites: Rust, wasm-pack
cargo install wasm-pack
# Clone and build
git clone https://github.com/parisxmas/OxiDB.git
cd OxiDB/oxidb-wasm
./build.sh
# Output in pkg/
oxidb_wasm.d.ts)