No matter if you’re using Redux, MobX, or just a simple JS
Map()
in your Frontend - These storage methods are not optimized for large-scale data, often buckling under the weight of having to handle a couple thousand objects at once. So, why not bring the queries, indices, convenience and raw speed of databases to the frontend?
retrieving all users named “Alice” or “Charlie” for an array of 100.000 items
blinkDB is a strongly optimized, blazingly fast database just for your frontend. It uses the same techniques & data structures as existing databases in order to speed up the retrieval of items, resulting in incredible performance, regardless if you’re working with 10.000 or 1.000.000 database entities.
interface User { id: string; name: string; age: number; }
interface Todo { uuid: string; description: string; }
const db = createDB();
const userTable = createTable<User>(db, "users")();
const todoTable = createTable<Todo>(db, "todos")({
primary: ["uid"] // '"uid"' is not assignable to 'keyof Todo'
});
// First 100 users named Alice with an age from 30 to 55
const users = await many(userTable, {
where: {
name: 'Alice',
age: { between: [30, 55] }
},
limit: {
take: 100
}
});
// Either watch for changes on the whole table...
await watch(userTable, users => {
console.log('All users in the database:', users);
});
// ...or specify a filter
await watch(userTable, { where: { age: { lt: 5 } } }, babies => {
console.log('All babies in the database:', babies);
});