https://github.com/co2-git/db.io
Socket RAM On-Demand Event-Driven DataBase in NodeJS
https://github.com/co2-git/db.io
Last synced: 11 months ago
JSON representation
Socket RAM On-Demand Event-Driven DataBase in NodeJS
- Host: GitHub
- URL: https://github.com/co2-git/db.io
- Owner: co2-git
- Created: 2015-04-09T09:39:05.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-09T09:38:07.000Z (about 11 years ago)
- Last Synced: 2025-03-27T11:44:48.194Z (about 1 year ago)
- Language: JavaScript
- Size: 80.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
db.io `alpha`
============
# Minimalistic database service
`db.io` is a server/client database written in JavaScript with the following features:
- Memory database (data is stored in RAM)
- TCP socket server (fast socket connexion)
- Event-driven (all clients get notified in real time of any watched events)
# About
`db.io` is the on-the-go solution to create a database server. The database server uses TCP sockets and data is stored in the RAM as JSON. A client is provided to execute CRUD queries. The database server is emitting events so a client get be used as a listener.
# Usage
```bash
npm install db.io
```
```js
var dbio = require('db.io');
var players = dbio.client('players');
// Get all players
players
.toArray()
.then(function (players) {});
// Insert player
players
.push({ 'name': 'Toni' })
.then(function (players) {});
// Get last player which name is Toni
players
.toArray()
.limit(1)
.reverse()
.filter(function (player) {
return player.name === 'Toni';
)
.then(function (players) {});;
// Update player
players
.limit(1)
.reverse()
.filter(function (player) {
return player.name === 'Toni';
)
.map(function (player) {
player.score += 100;
return player;
})
.then(function (players) {});
// Remove Toni if his score is below 1000
players
.limit(1)
.reverse()
.filter(function (player) {
return player.name === 'Toni' && score < 100;
)
.remove()
.then(function (players) {});
```
# Command Line
We ship with a command line utility:
```bash
npm install -g db.io
$ dbio push players '{"test":"foo"}'
server: dbio://localhost:7000
message: players pushed
data:
0: {"test":"foo"}
$ dbio toArray players limit=10
server: dbio://localhost:7000
message: players toArray
length: 1
data:
0: {"test":"foo"}
$ dbio pull players 0
```