diff --git a/README.md b/README.md index 43cd8855..303bba87 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ -gun [](https://travis-ci.org/amark/gun) +gun [](https://travis-ci.org/amark/gun) [](https://gitter.im/amark/gun?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) === GUN is a realtime, decentralized, embedded, graph database engine. ## Getting Started +For the browser, try out this [tutorial](https://dl.dropboxusercontent.com/u/4374976/gun/web/think.html). This README is for GUN servers. + If you do not have [node](http://nodejs.org/) or [npm](https://www.npmjs.com/), read [this](https://github.com/amark/gun/blob/master/examples/install.sh) first. Then in your terminal, run: @@ -35,42 +37,21 @@ These are the default persistence layers, they are modular and can be replaced o Using S3 is recommended for deployment, and using a file is recommended for local development. -Now you can save your first object, and create a reference to it. +## Demos -```javascript -gun.set({ hello: 'world' }).key('my/first/data'); -``` - -Altogether, try it with the node hello world web server which will reply with your data. - -```javascript -var Gun = require('gun'); -var gun = Gun({ file: 'data.json' }); -gun.set({ hello: 'world' }).key('my/first/data'); - -var http = require('http'); -http.createServer(function(req, res){ - gun.load('my/first/data', function(err, data){ - res.writeHead(200, {'Content-Type': 'application/json'}); - res.end(JSON.stringify(data)); - }); -}).listen(1337, '127.0.0.1'); -console.log('Server running at http://127.0.0.1:1337/'); -``` - -Fire up your browser and hit that URL - you'll see your data, plus some gun specific metadata. - -## Examples - -Try out some online [examples](http://gunjs.herokuapp.com/) or run them yourself with the following command: +The examples included in this repo are online [here](http://gunjs.herokuapp.com/), you can run them locally by: ```bash -git clone http://github.com/amark/gun -cd gun/examples && npm install -node express.js 8080 +sudo npm install gun +cd node_modules/gun +node examples/http.js 8080 ``` -Then visit [http://localhost:8080](http://localhost:8080) in your browser. +Then visit [http://localhost:8080](http://localhost:8080) in your browser. If that did not work it is probably because npm installed to a global directory, to fix this try `mkdir node_modules` in your desired directory and re-run the above commands. + +## WARNINGS + +Version 0.2.0 breaks **everything** from 0.1.x, see [#54](/../../issues/54) to migrate (`.all` is not implemented yet). GUN is not stable, and therefore should not be trusted in a production environment. ## API @@ -87,20 +68,20 @@ In gun, it can be helpful to think of everything as field/value pairs. For examp "email": "mark@gunDB.io" } ``` -Now, we want to save this object to a key called `usernames/marknadal`. We can do that like this: +Now, we want to save this object to a key called `'usernames/marknadal'`. We can do that like this: ```javascript -gun.set({ +gun.put({ username: "marknadal", name: "Mark Nadal", email: "mark@gunDB.io" }).key('usernames/marknadal'); ``` -We can also pass `set` a callback that can be used to handle errors: +We can also pass `put` a callback that can be used to handle errors: ```javascript -gun.set({ +gun.put({ username: "marknadal", name: "Mark Nadal", email: "mark@gunDB.io" @@ -114,33 +95,40 @@ gun.set({ Once we have some data stored in gun, we need a way to get them out again. Retrieving the data that we just stored would look like this: ```javascript -gun.load('usernames/marknadal').get(function(user){ +gun.get('usernames/marknadal').val(function(user){ console.log(user.name); // Prints `Mark Nadal` to the console }); ``` -Basically, this tells gun to check `usernames/marknadal`, and then return the object it finds associated with it. For more information, including how to save relational or document based data, [check out the wiki](https://github.com/amark/gun/wiki). +Basically, this tells gun to check `'usernames/marknadal'`, and then return the object it finds associated with it. For more information, including how to save relational or document based data, [check out the wiki](https://github.com/amark/gun/wiki). --- -## YOU -We're just getting started, so join us! Being lonely is never any fun, especially when programming. -I want to help you, because my goal is for GUN to be the easiest database ever. -That means if you ever get stuck on something for longer than 5 minutes, -you should talk to me so I can help you solve it. -Your input will then help me improve gun. -We are also really open to contributions! GUN is easy to extend and customize: +## YOU +Being lonely is never any fun, especially when programming. +Our goal is for GUN to be the easiest database ever, +which means if you ever get stuck on something for longer than 5 minutes, +let us know so we can help you. Your input is invaluable, +as it enables us where to refine GUN. So drop us a line in the [](https://gitter.im/amark/gun?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)! Or join the [mail list](https://groups.google.com/forum/#!forum/g-u-n). + +Thanks to the following people who have contributed to GUN, via code, issues, or conversation: + +[agborkowski](https://github.com/agborkowski), [alexlafroscia](https://github.com/alexlafroscia), [anubiann00b](https://github.com/anubiann00b), [bromagosa](https://github.com/bromagosa), [coolaj86](https://github.com/coolaj86), [d-oliveros](https://github.com/d-oliveros), [danscan](https://github.com/danscan), [forrestjt](https://github.com/forrestjt), [gedw99](https://github.com/gedw99), [HelloCodeMing](https://github.com/HelloCodeMing), [JosePedroDias](https://github.com/josepedrodias), [onetom](https://github.com/onetom), [ndarilek](https://github.com/ndarilek), [phpnode](https://github.com/phpnode), [riston](https://github.com/riston), [rootsical](https://github.com/rootsical), [rrrene](https://github.com/rrrene), [ssr1ram](https://github.com/ssr1ram), [Xe](https://github.com/Xe), [zot](https://github.com/zot) + +This list of contributors was manually compiled, alphabetically sorted. If we missed you, please submit an issue so we can get you added! + +## Contribute + +Extending GUN or writing modules for it is as simple as: `Gun.on('opt').event(function(gun, opt){ /* Your module here! */ })` -It is also important to us that your database is not a magical black box. -So often our questions get dismissed with "its complicated hard low level stuff, let the experts handle it." -And we do not think that attitude will generate any progress for people. -Instead, we want to make everyone an expert by actually getting really good at explaining the concepts. -So join our community, in the quest of learning cool things and helping yourself and others build awesome technology. +We also want our database to be comprehensible, not some magical black box. +So often database questions get dismissed with "its complicated hard low level stuff, let the experts handle it". +That attitude prevents progress, instead we welcome teaching people and listening to new perspectives. +Join along side us in a quest to learn cool things and help others build awesome technology! - - [](https://gitter.im/amark/gun?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) (all chats relating to GUN and development should be here! IRC style) - - Google Group: https://groups.google.com/forum/#!forum/g-u-n (for slower threaded discussions) +We need help on the following roadmap. ## Ahead - ~~Realtime push to the browser~~ @@ -151,40 +139,11 @@ So join our community, in the quest of learning cool things and helping yourself - Test more - Bug fixes - Data Structures: - - ~~Groups~~ - - Linked Lists - - Collections (hybrid: linked-groups/paginated-lists) + - ~~Sets~~ (Table/Collections, Unordered Lists) - CRDTs - OT - Query: - SQL - MongoDB Query Documents - Neo4j Cypher - - Gremlin Query Language - - -## Contributors - -Thanks to the following people who have contributed to GUN: - - [agborkowski](https://github.com/agborkowski) - - [alexlafroscia](https://github.com/alexlafroscia) - - [anubiann00b](https://github.com/anubiann00b) - - [bromagosa](https://github.com/bromagosa) - - [coolaj86](https://github.com/coolaj86) - - [d-oliveros](https://github.com/d-oliveros) - - [danscan](https://github.com/danscan) - - [forrestjt](https://github.com/forrestjt) - - [gedw99](https://github.com/gedw99) - - [HelloCodeMing](https://github.com/HelloCodeMing) - - [JosePedroDias](https://github.com/josepedrodias) - - [onetom](https://github.com/onetom) - - [ndarilek](https://github.com/ndarilek) - - [phpnode](https://github.com/phpnode) - - [riston](https://github.com/riston) - - [rootsical](https://github.com/rootsical) - - [rrrene](https://github.com/rrrene) - - [ssr1ram](https://github.com/ssr1ram) - - [Xe](https://github.com/Xe) - - [zot](https://github.com/zot) - -This list of contributors was manually compiled; if you have contributed in code, issues, or conversation and your GitHub username is not listed, please submit an issue so we can get you added! + - Gremlin Query Language \ No newline at end of file diff --git a/examples/todo/index.html b/examples/todo/index.html index ad1fe935..92dd811c 100644 --- a/examples/todo/index.html +++ b/examples/todo/index.html @@ -11,20 +11,18 @@ function ready(){ var $ = document.querySelector.bind(document); var gun = Gun(location.origin + '/gun').get('example/todo/data'); - gun.not(function(){ - return this.put({hello: "world!"}).key('example/todo/data'); - }).on(function renderToDo(val){ + gun.on(function renderToDo(val){ var todoHTML = ''; - for(key in val) { - if(!val[key] || key == '_') continue; - todoHTML += '