All Projects → gundb → Gun Level

gundb / Gun Level

LevelDB storage plugin for gunDB

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Gun Level

Glusterfs Java Filesystem
GlusterFS for Java
Stars: ✭ 50 (-27.54%)
Mutual labels:  storage
Django minio
Django app to use Minio Server as file storage.
Stars: ✭ 59 (-14.49%)
Mutual labels:  storage
Recoil Persist
Package for recoil state manager to persist and rehydrate store
Stars: ✭ 66 (-4.35%)
Mutual labels:  storage
Level
Fast & simple storage. A Node.js-style LevelDB wrapper for Node.js, Electron and browsers.
Stars: ✭ 1,071 (+1452.17%)
Mutual labels:  leveldb
Thanos
Highly available Prometheus setup with long term storage capabilities. A CNCF Incubating project.
Stars: ✭ 9,820 (+14131.88%)
Mutual labels:  storage
Heketi
RESTful based volume management framework for GlusterFS
Stars: ✭ 1,106 (+1502.9%)
Mutual labels:  storage
Amplify Js
A declarative JavaScript library for application development using cloud services.
Stars: ✭ 8,539 (+12275.36%)
Mutual labels:  storage
Oblecto
Oblecto is a media server, which streams media you already own, and is designed to be at the heart of your entertainment experience. It runs on your home server to index and analyze your media such as Movies and TV Shows and presents them in an interface tailored for your media consupmtion needs.
Stars: ✭ 67 (-2.9%)
Mutual labels:  storage
Miniflix
Miniflix - A smaller version of Netflix powered by Cloudinary
Stars: ✭ 58 (-15.94%)
Mutual labels:  storage
Wsend
wsend: The opposite of wget
Stars: ✭ 64 (-7.25%)
Mutual labels:  storage
Hexa
Hexa: The ultimate companion for Azure. Setup and deploy in seconds
Stars: ✭ 56 (-18.84%)
Mutual labels:  storage
Distributedsystem Series
📚 深入浅出分布式基础架构,Linux 与操作系统篇 | 分布式系统篇 | 分布式计算篇 | 数据库篇 | 网络篇 | 虚拟化与编排篇 | 大数据与云计算篇
Stars: ✭ 1,092 (+1482.61%)
Mutual labels:  storage
String Interner
A data structure to efficiently intern, cache and restore strings.
Stars: ✭ 60 (-13.04%)
Mutual labels:  storage
Bleeper
Library to manage your firmware configurations written in C++
Stars: ✭ 54 (-21.74%)
Mutual labels:  storage
Terraform Aws S3 Log Storage
This module creates an S3 bucket suitable for receiving logs from other AWS services such as S3, CloudFront, and CloudTrail
Stars: ✭ 65 (-5.8%)
Mutual labels:  storage
Radosgw Admin4j
A Ceph Object Storage Admin SDK / Client Library for Java ✨🍰✨
Stars: ✭ 50 (-27.54%)
Mutual labels:  storage
Goshare
Go Share your TimeSeries/NameSpace/KeyVal DataStore (using leveldb) over HTTP &/or ZeroMQ
Stars: ✭ 59 (-14.49%)
Mutual labels:  leveldb
Blivet
A python module for configuration of block devices
Stars: ✭ 68 (-1.45%)
Mutual labels:  storage
Coursera Dl
Script for downloading Coursera.org videos and naming them.
Stars: ✭ 8,609 (+12376.81%)
Mutual labels:  storage
Blockstack Browser
The Blockstack Browser
Stars: ✭ 1,119 (+1521.74%)
Mutual labels:  storage

gun-level

Travis npm Gitter

LevelDB is awesome. It's awesomer with gun.

indexedDB NOW SUPPORTED IN MAIN GUN REPO - THIS REPO NO LONGER MAINTAINED

The main GUN repo now has lib/rindexed that can be used like so, now built on the RAD storage engine for GUN.

If you still need NodeJS LevelDB bindings, consider writing a RAD adapter, or use this project - please contribute and maintain it for others, as it is now deprecated.

Overview

GunDB is a graph database engine with real-time sync and offline-editing. Although gun comes with storage and sync out of the box, it's design is pluggable, so you can still use your favorite storage backend or transport layer by using an adapter.

LevelDB operates on a similar paradigm. It ships with an interface called LevelUP that gives all the methods you'd expect from a storage engine (like get, put, batch, etc.) and forwards those to a lower-level database (it uses LevelDOWN by default).

Arguably the most valuable aspect of level is it's ecosystem. There are tons are plugins, backends, dashboards, and utilities made specifically for level. It's kinda like a database buffet.

Here, check out their list of modules!

If you're feeling stressed, don't worry. LevelDB comes out of the box as a quite capable database, and if you don't want to dabble with plugins and configs, there's no need.

So what happens when you combine Level with GunDB? You get the power and control of level right alongside the ease of gun.

That's what this library does.

Usage

To get started, you'll first need to install gun-level.

If you're unfamiliar with npm, you can get started here

$ npm install --save gun-level gun

Now require them from your node project.

// Import the `Gun` library
const Gun = require('gun')

// Imported for side effects, adds level adapters.
// MUST be required after Gun to work
require('gun-level')

Once they're imported you can create a new Gun database:

const gun = new Gun({
	// We'll put options here in a moment.
})

Sweet, you're set up! However, gun-level won't do anything unless you pass it a levelDB instance through the Gun constructor. For that, you'll need to download the Node levelup package.

There are some differences between levelup v1 and v2 so be sure to note which version you're using.

levelup v1

$ npm install --save levelup leveldown

If you get a build error at this step, replace all examples of leveldown with jsondown.

// Import the two libraries
const levelup = require('levelup')
const leveldown = require('leveldown')

// Create a new level instance which saves
// to the `data/` folder.
const levelDB = levelup('data', {
	db: leveldown,
})

levelup >v2

Note that Levelup v2 only supports Node >6.

$ npm install --save levelup leveldown encoding-down
// Import the required libraries
const levelup = require('levelup')
const encode = require('encoding-down')
const leveldown = require('leveldown')

// Create a new level instance which saves
// to the `data/` folder.
const levelDB = levelup(
	encode(
		leveldown('data'),
		{ valueEncoding: 'json' }
	)
)

Instantiating Gun with Level

Now we can pass our new levelDB instance to the Gun constructor.

const Gun = require('gun')
require('gun-level')

// ... instantiate LevelDB per above

// Pass LevelDB instance into Gun
const gun = new Gun({
	level: levelDB
})

Done! Now your gun database will store it's graph in your Level DB!

Let's try a few things...

const bob = gun.get('bob').put({ name: 'Bob' })
const dave = gun.get('dave').put({ name: 'Dave' })

// Write a fun circular reference.
bob.get('friend').put(dave)
dave.get('friend').put(bob)

// Print the data!
bob.get('friend').val(friend => {
	console.log(friend.name) // Dave
});

// Now with a circular reference
bob.get('friend').get('friend').val(friend => {
	console.log(friend.name) // Bob
});

That's pretty much all there is to the gun-level API. If you're unfamiliar with gun's API, here's a good reference.

Advanced Levelry

You've seen the basics, but it's not enough. You crave more power.

To exchange backends with level, like Riak, Mongo, IndexedDB, etc., you can find the official list of storage backends here. Usually it's just a matter of passing the module as the db option to levelup.

Here's an example with MongoDB using mongodown:

const levelup = require('levelup')
const mongoDown = require('mongodown')

// Initialize Level
const levelDB = levelup('localhost:27017/YOUR_COLLECTION_NAME', {
	db: mongoDown,
})

// Initialize Gun
const gun = new Gun({
	level: levelDB,
	file: false,
})

Here's another example with IndexedDB using level-js:

const levelup = require('levelup')
const leveldown = require('level-js')
const encode = require('encoding-down')

// Initialize Level
const levelDB = levelup(encode(leveldown('my-big-db'), { valueEncoding: 'json' }))

// Initialize Gun
const gun = Gun({
    level: levelDB,
    localStorage: false,
})

Even if you're content with the default levelDB setup, I really recommend you scan this list of plugins. It's inspiring what the community has built.

gun-level will try to read and write values as json. If you're having trouble getting a plugin to work, or keep seeing "[object Object]", make sure it's using the json value encoding.

Getting Support

If you're running into problems, feel free to either post an issue on GitHub or chat with us humans in the Gitter channel.

Installing from Source

Clone the repo and install the dependencies:

$ git clone https://github.com/PsychoLlama/gun-level.git
$ cd gun-level
$ npm install

Running Tests

# In directory `gun-level`
$ npm test

Building

$ npm run build
# Compiles to folder `dist/`

Contributors

Sponsored by the fabulous people at GunDB.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].