-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from UlisesGascon/dev
Release v0.0.2
- Loading branch information
Showing
14 changed files
with
953 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# EditorConfig helps developers define and maintain consistent coding styles | ||
# between different editors and IDEs. | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,10 @@ jspm_packages | |
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Notes | ||
IDEAS | ||
IGNORE | ||
|
||
# Testing results | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,279 @@ | ||
 | ||
 | ||
 | ||
 | ||
|
||
# GoblinDB | ||
|
||
An amazing, simple and fun database for humans | ||
 | ||
|
||
### Fear the Goblin! | ||
|
||
**An amazing, simple and fun database for humans** | ||
|
||
|
||
### Goblin Philosophy | ||
|
||
- Coding is fun, so databases must be fun too. | ||
- Data is the king. | ||
- Data should be stored in the system as a file when a change happend. | ||
- Data storage in the system must be hackable. | ||
- The database can lead or connect your server components | ||
- Events are great... because we are asynchronous | ||
- We prefer facts over promises: facts are there, promises maybe yes or not. In fact, we're talking about callbacks. | ||
|
||
|
||
#### Demo | ||
You can run a demo in 4 steps! | ||
|
||
1. Clone this repository | ||
```bash | ||
git clone https://github.com/UlisesGascon/GoblinDB | ||
``` | ||
|
||
2. Enter in the folder | ||
```bash | ||
cd GoblinDB | ||
``` | ||
|
||
3. Install the dependencies | ||
```bash | ||
npm install | ||
``` | ||
|
||
4. Run *fear_the_goblin.js* | ||
```bash | ||
node fear_the_goblin.js | ||
``` | ||
|
||
#### Documentation | ||
|
||
**Add it to your Node.js project** | ||
- In your terminal... | ||
```bash | ||
npm install goblindb --save | ||
``` | ||
- In your file.. | ||
```javascript | ||
var GDB = require("./goblin"); | ||
var http = require("http"); | ||
|
||
var goblinDB = GDB(); | ||
``` | ||
|
||
**Reitrieving data** | ||
|
||
By default Goblin will create an empty json file as database storage, if the file exist it will added to Goblin. | ||
|
||
Just for the example, current database status... as you can see is a JSON file: | ||
- *goblin_bd.json*: | ||
```json | ||
{"hello":"world!","array":["aaaa",true,5],"objectData":{"property": 1}} | ||
``` | ||
|
||
- *get*. Return the information from a key or the whole database | ||
```javascript | ||
var GDB = require("./goblin"); | ||
var http = require("http"); | ||
|
||
var goblinDB = GDB(); | ||
|
||
console.log(goblinDB.get()) | ||
// {"hello":"world!","array":["aaaa",true,5],"objectData":{"property": 1}} | ||
|
||
console.log(goblinDB.get("hello")) | ||
// {"hello":"world!"} | ||
``` | ||
|
||
**Saving data** | ||
|
||
You have many options to save data. As Goblin is a key/value database you need to know what is the key that you want to use/create. | ||
|
||
You can storage all the data that you want except functions. Until the next release. | ||
|
||
- *set(key, data)*. Write or replace data to a defined key (optional) | ||
```javascript | ||
var GDB = require("./goblin"); | ||
var http = require("http"); | ||
|
||
var goblinDB = GDB(); | ||
|
||
// set data in db.admin | ||
goblinDB.set({"name": "Ulises", "role": "developer"}, "admin"); | ||
|
||
// set data in root | ||
goblinDB.set({"hello": "Human...!"}); | ||
``` | ||
|
||
- *push(data)*. Write data in a new key (random name added) | ||
```javascript | ||
var GDB = require("./goblin"); | ||
var http = require("http"); | ||
|
||
var goblinDB = GDB(); | ||
|
||
goblinDB.push({"name": "Ulises", "role": "developer"}) | ||
``` | ||
|
||
- *update(data, key)*. Add and modify data to a defined key | ||
```javascript | ||
var GDB = require("./goblin"); | ||
var http = require("http"); | ||
|
||
var goblinDB = GDB(); | ||
|
||
goblinDB.update({"name": "CodingCarlos", "friends": ["Ulises", "Jose"]}, "admin"); | ||
``` | ||
|
||
**Fun with Events** | ||
You can use events in order to react to changes in the database. All the events are managed internally by Goblin inside as hooks. | ||
|
||
You can specify the trigger event: | ||
- add | ||
- update | ||
- delete | ||
- reconfigure | ||
- change, in any case it will be triggered. | ||
|
||
The event will return an object that contains previous data and current data. | ||
At the moment the the listeners can be added to the database root, but in the next release it will possible to focus in on or more specific paths | ||
|
||
- *on()*, Add a new function to be triggered on a specific change. | ||
```javascript | ||
var GDB = require("./goblin"); | ||
var http = require("http"); | ||
|
||
var goblinDB = GDB(); | ||
|
||
goblinDB.on('change', function(changes){ | ||
console.log("cambio:", changes) | ||
console.log("====================") | ||
}); | ||
``` | ||
|
||
- *off()*, Remove a previous record event | ||
```javascript | ||
var GDB = require("./goblin"); | ||
var http = require("http"); | ||
|
||
var goblinDB = GDB(); | ||
|
||
goblinDB.on('change', function(changes){ | ||
console.log("cambio:", changes) | ||
console.log("====================") | ||
}); | ||
|
||
// more code... | ||
|
||
goblinDB.off('change', function(changes){ | ||
console.log("cambio:", changes) | ||
console.log("====================") | ||
}); | ||
``` | ||
|
||
**Extra features** | ||
Some extra features that maybe can help you. | ||
|
||
- *getConfig() & updateConfig*, modify/replace/extend configuration. | ||
```javascript | ||
var GDB = require("./goblin"); | ||
var http = require("http"); | ||
|
||
var goblinDB = GDB(); | ||
|
||
console.log(goblinDB.getConfig()) | ||
// { logPrefix: '[GoblinDB]', file: './goblin_bd.json', recordChanges: true } | ||
|
||
goblinDB.updateConfig({ logPrefix: '[GoblinDB-modify]'}) | ||
|
||
console.log(goblinDB.getConfig()) | ||
// { logPrefix: '[GoblinDB-modify]', file: './goblin_bd.json', recordChanges: true } | ||
``` | ||
|
||
- *stopStorage() & startStorage()*. enable/disable the storage in disk. | ||
```javascript | ||
var GDB = require("./goblin"); | ||
var http = require("http"); | ||
|
||
var goblinDB = GDB(); | ||
|
||
goblinDB.stopStorage(); | ||
|
||
// more code that will not touch be stored in the disk... | ||
|
||
goblinDB.startStorage(); | ||
// Now the current GoblinDB will be stored in disk and it will keep doing it | ||
``` | ||
|
||
### Testing | ||
|
||
You can test your changes... | ||
|
||
```bash | ||
npm test | ||
``` | ||
|
||
### Future Implementations | ||
|
||
- [ ] Logo, branding... | ||
- [ ] Landing Page. | ||
- [ ] Support multidimensional navigation in the database (.ref() method). | ||
- [ ] Support to chain methods. | ||
- [ ] Add basic query methods. | ||
- [ ] Add Avance query methods. | ||
- [ ] Add support to .once() method for events. | ||
- [ ] Add support to UID in events. | ||
- [ ] Support .goblin extension for database in order to record raw database with objects, functions... | ||
- [ ] Support .json compatibility for database. | ||
- [ ] Additional events to support (config changes, etc...). | ||
- [ ] Add additional support to Backup goblin with other databases like Firebase, Mongo... in real time. | ||
- [ ] Full documentation in JSDoc. | ||
- [ ] Gulp Tasks Improves. | ||
- [ ] Example Folder. | ||
- [ ] Test support for Events using Sinon. | ||
- [ ] Test refactor in order to separate more the test cases. | ||
|
||
### Achievements | ||
|
||
### v.0.0.2 | ||
|
||
**Main target:** | ||
- Develop the basics key functionalities (methods) | ||
- Key/Value operative database | ||
- Event support | ||
- Database recorded as file | ||
- Minimum config setup | ||
|
||
**Features:** | ||
- Added support to JSDoc | ||
- Added Gulp Tasks | ||
- Added Basic Testing with Mocha, Chai and Istanbul | ||
- Added .editorconfig | ||
- Added esLint support | ||
- Roadmap added | ||
- Added File structure | ||
- Added minimal validation | ||
- Added basic documentation | ||
- Added GoblinDB as Module | ||
- Added GoglinDB Helpers as an independente module | ||
- Added support to store the data on demand as JSON | ||
- Added full support to events | ||
- Added support to key changes in events | ||
- Added Method on | ||
- Added Method off | ||
- Added Method getConfig | ||
- Added Method setConfig | ||
- Added Method stopStorage | ||
- Added Method startStorage | ||
- Added Method get | ||
- Added Method push | ||
- Added Method set | ||
- Added Method update | ||
|
||
|
||
### v.0.0.1 | ||
|
||
**Features:** | ||
|
||
 | ||
**Notes:** | ||
Just a "Hello world" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
logPrefix: "[GoblinDB]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
 | ||
 | ||
 | ||
 | ||
|
||
# GoblinDB | ||
|
||
### Fear The Goblin | ||
|
||
**Under development - More news soon** | ||
|
||
 | ||
|
||
### This is just the beginning of a long journey | ||
|
||
**An amazing, simple and fun database for humans** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"tags": { | ||
"allowUnknownTags": true | ||
}, | ||
"opts": { | ||
"destination": "./docs/jsdoc" | ||
}, | ||
"plugins": [ | ||
"plugins/markdown" | ||
], | ||
"templates": { | ||
"cleverLinks": false, | ||
"monospaceLinks": false, | ||
"default": { | ||
"outputSourceFiles": true | ||
}, | ||
"path": "ink-docstrap", | ||
"theme": "simplex", | ||
"navType": "vertical", | ||
"linenums": true, | ||
"dateFormat": "MMMM Do YYYY, h:mm:ss a" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var GDB = require("./goblin"); | ||
var http = require("http"); | ||
|
||
var goblinDB = GDB(); | ||
|
||
console.log("Fear the Goblin!") | ||
console.log("Current Internal configuration:", goblinDB.getConfig()) | ||
|
||
goblinDB.on('change', function(changes){ | ||
console.log("-- change detected!:", changes) | ||
console.log("====================") | ||
}); | ||
|
||
var datosOriginales = goblinDB.get(); | ||
//console.log("datosOriginales:", datosOriginales); | ||
|
||
goblinDB.set({"data": "world!", "data2": "Hiiiii"}); | ||
goblinDB.update({"new data": "hellooo....", "new array": ["aaaa", true, 2], "data": "cambiado!"}) | ||
|
||
var datosActuales = goblinDB.get(); | ||
//console.log("datosActuales:", datosActuales) | ||
|
||
console.log("Let's make something fun....") | ||
http.get("http://eventpoints.osweekends.com/api/events", function(res){ | ||
var body = ''; | ||
|
||
res.on('data', function(chunk){ | ||
body += chunk; | ||
}); | ||
|
||
res.on('end', function(){ | ||
goblinDB.update({"events": JSON.parse(body)}); | ||
console.log("Check", goblinDB.getConfig().file); | ||
}); | ||
}).on('error', function(e){ | ||
console.log("Got an error: ", e); | ||
}); |
Oops, something went wrong.