Github DataBase
github repository database
📝 Table of Contents
🧐 About
use github repository as database
🏁 Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Installing
yarn add @sl-code-lords/github-db
or
npm i @sl-code-lords/github-db
🎈 Usage
var Github_db = require('@sl-code-lords/github-db')
var config={ github_token: 'token', user_name:'user_name', repo:'test_github_db',is_private_repo:true }
var git = new Github_db(config)
Config
const config = {
github_token,
user_name,
repo,
commit_message,
committer_mail,
committer_name,
use_template,
is_private_repo
}
Connecting..
const is_conn = await git.connect()
true
File Model
var File = git.File('hello.txt','Init','Files/')
var init = await File.upload_data(Buffer.from('test file upload', 'utf-8'))
var del = await File.delete_file()
true
true
String Model
var password = ''
var session = git.stringModel('session','Init','DB/',password)
var add = await session.update_data('Hello I Am Ravindu Manoj -')
var second_add = await session.update_data('@ravindu01manoj')
var third_add = await session.update_data('replacement add',true)
var get_data = await session.get_data()
var del = await session.delete_model()
Hello I Am Ravindu Manoj -
Hello I Am Ravindu Manoj -@ravindu01manoj
replacement add
replacement add
true
Array Model
var password = ''
var list = git.arrayModel('list','Init','DB/',password)
var add = await list.update_data([1,'mango'])
var second_add = await list.update_data(['banana','apple'])
var third_add = await list.update_data(['cat','dog','ant'],true)
var get_data = await list.get_data()
var del = await list.delete_model()
[ 1, 'mango' ]
[ 1, 'mango', [ 'banana', 'apple' ] ]
[ 'cat', 'dog', 'ant' ]
[ 'cat', 'dog', 'ant' ]
true
Object Model
var password = ''
var item = git.objectModel('item','Init','DB/',password)
var add = await item.update_data({name : 'Ravindu',age:'21'})
var second_add = await item.update_data({country : 'sri_lanka',age:22,language : 'sinhala'})
var third_add = await item.update_data({game:'cricket',year: 2023},true)
var get_data = await item.get_data()
var del = await item.delete_model()
{ name: 'Ravindu', age: '21' }
{ name: 'Ravindu', age: 22, country: 'sri_lanka', language: 'sinhala' }
{ game: 'cricket', year: 2023 }
{ game: 'cricket', year: 2023 }
true
✍️ Authors
See also the list of contributors who participated in this project.