A TypeScript embedded database
npm install camadbCamaDB is a NoSQL embedded database written in pure TypeScript for Node, Electron and browser-based environments.

- I had issues getting SQLite to work with webpack due to its native build
- SQLite doesn't (by default) return native JS data types (Dates in particular)
- Other NoSQL embedded databases seem to be largely abandoned
- Most other NoSQL embedded databases seem to be limited by V8's hard string length limits
yarn add reflect-metadata
yarn add camadb
`
OR
`
npm install reflect-metadata --save
npm install camadb --save
`$3
All of these config options are optional:
- path - Where you want the data to be stored - default is ./.cama or cama for indexeddb and localstorage
- persistenceAdapter - How you want to persist your data - fs, indexeddb, localstorage or inmemory
- logLevel - info or debug
`
import { Cama } from 'camadb'
const database = new Cama({
path: './.cama',
persistenceAdapter: 'fs',
logLevel: 'debug'
});
`$3
- Use the columns field to add specific data types for rows. This does _need_ to be done for each column, but is essential for date objects
- Indexes aren't currently implemented, but the lookup is still very fast across 10 million rows
`
const collection = await database.initCollection('test', {
columns: [{
type:'date',
title:'date'
}],
indexes: [],
});
`$3
`
await collection.insertOne({
_id: 'test',
name: 'Dummy field',
description: Data,
});
`
$3
`
await collection.insertMany([{
_id: 'test',
name: 'Dummy field',
description: Data,
}]);`$3
CamaDB uses a MongoDB style query language, powered by SiftJS. Have a look at that project to see the full capabilities of that library.
`
const findResult = await collection.findMany({
_id: {
$gte: 50000,
},
},
{
sort:{
desc: x => x._id
},
offset: 100,
limit: 100
});
`$3
Again we use a MongoDB style language for data updates, for this we use obop
`
await collection.updateMany({
_id:3
}, {
$set: {
steve:"steve"
}
});
`$3
We use Mingo for aggregation - currently lookup commands aren't supported.
`
const aggregationResult = await collection.aggregate([{
$match:{
_id:3
}
}]);
``