LuxDB is a tiny, lightweight, 0 dependency, easy-to-use JSON-based database
const luxdb = new LuxDB('cache/testdb.json');
luxdb.set('users', []);
luxdb.point('users');
luxdb.push({'id': 0, 'name': 'Joe Doe'})
console.log(luxdb.get({'id': 0}));
// Prints { id: 0, name: 'Joe Doe' }
luxdb.point('users');
luxdb.point('..'); // Sets the pointer to the last pointer
luxdb.point('.'); // Sets the pointer to the database (starting point)
luxdb.set('users', []);
luxdb.point('users'); // Always need to point to something first
luxdb.push({id: 0, name: 'Joe Doe'});
luxdb.point('users')
.push({id: 0, name: 'Joe Doe', gender: 'male'})
.push({id: 1, name: 'Jane Doe', gender: 'female'})
.push({id: 2, name: 'Aadam Doe', gender: 'male'})
.push({id: 3, name: 'Eve Doe', gender: 'female'})
let query = luxdb.point('users').get({id: 2})
console.log(query);
>> [ {id: 2, name: 'Aadam Doe', gender: 'male'} ]
let query = luxdb.point('users').get({gender: 'female'})
console.log(query);
>> [ {id: 0, name: 'Joe Doe', gender: 'male'}, {id: 2, name: 'Aadam Doe', gender: 'male'} ]
luxdb.update({name: 'Jane Doe'}, {name: 'Jane Janett Doe'})
luxdb.point('users')
.push({id: 0, name: 'Joe Doe', gender: 'male'})
.push({id: 1, name: 'Jane Doe', gender: 'female'})
.conf({id: luxdb.configs.AUTO_INCREMENT})
.push({name: 'Aadam Doe', gender: 'male'}) // Will have id: 2
.push({name: 'Eve Doe', gender: 'female'}) // Will have id: 3
For a full example implementation, see the file tests/example.js.
Test data structure: {'n': [Attributes]}
No. of Attributes Written | Time Elapsed | Attributes Wrote/sec | Data Size Wrote |
---|---|---|---|
100,000 | 30ms | 3,333,333,333/sec | 575 KB |
1,000,000 | 40ms | 25,000,000,000/sec | 6,56 MB |
Ways to contribute:
- Check for open issues
- Read the
TODO
file - Make an improvement
- Fork this repository
- Create a new branch (optional)
- Clone it
- Make your changes
- Upload them
- Make a pull request here
Copyright © Martin Kondor 2022.
MIT license, see the LICENSE file for more details.