A github-powered nosql database inspired by node-mongodb-native.
Connect to a ReGit database. This is a database-like wrapper for a GitHub repository that treats JSON objects as documents.
client.connect({
token: 'token',
username: 'username',
repo: 'dbname'
}, (err, db) => {
console.log(db.name) // print "dbname"
})
Fetch all collections for the current db.
db.collections((err, collections) => {
if (err) return console.error(err)
collections.forEach((collection) => console.log(collections.name))
// print "[ 'foo' ]"
})
Fetch a specific collection.
db.collection('foo', (err, collection) => {
if (err) return console.error(err)
console.log(collection.name) // print "foo"
})
If you do not need to fetch the collection information, you can also use it without a callback in the following way.
const collection = db.collection('foo')
console.log(collection.name) // print "foo"
Inserts an array of documents into ReGit. The callback is called
with (err, results)
.
Add a new object to the collection. The callback is called
with (err, item, id)
where id
is the id internally chosen
for this new item.
Requires nodejs.
$ npm install regit
Have a look to the examples folder.
$ npm test