@sl-code-lords/github-db
v1.1.0
Published
github repository database
Downloads
220
Readme
📝 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
- first you need to get github access token
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, // your github token
user_name, // your github username
repo, // repo name for github db
commit_message, // commit massage
committer_mail, // mail of any github account for commit
committer_name, // name for committer
use_template, // if you have template repo use_template : 'username/repo'
is_private_repo // if true repo will gen as private
}
Connecting..
const is_conn = await git.connect()
//is_conn
true
File Model
//init new file
var File = git.File('hello.txt','Init','Files/')
// upload file to github
var init = await File.upload_data(Buffer.from('test file upload', 'utf-8'))
//delete File From Github
var del = await File.delete_file()
//init
true
//del
true
String Model
var password = '' // password for enc file method
//init new String Model
var session = git.stringModel('session','Init','DB/',password)
// add new string
var add = await session.update_data('Hello I Am Ravindu Manoj -')
// + add string
var second_add = await session.update_data('@ravindu01manoj')
// replace new string
var third_add = await session.update_data('replacement add',true)
// get data from model
var get_data = await session.get_data()
// delete model
var del = await session.delete_model()
//add
Hello I Am Ravindu Manoj -
//second_add
Hello I Am Ravindu Manoj -@ravindu01manoj
//third_add
replacement add
//get_data
replacement add
//del
true
Array Model
var password = '' // password for enc file method
//init new Array Model
var list = git.arrayModel('list','Init','DB/',password)
// add new array
var add = await list.update_data([1,'mango'])
// + add array
var second_add = await list.update_data(['banana','apple'])
// replace new array
var third_add = await list.update_data(['cat','dog','ant'],true)
// get data from model
var get_data = await list.get_data()
// delete model
var del = await list.delete_model()
//add
[ 1, 'mango' ]
//second_add
[ 1, 'mango', [ 'banana', 'apple' ] ]
//third_add
[ 'cat', 'dog', 'ant' ]
//get_data
[ 'cat', 'dog', 'ant' ]
//del
true
Object Model
var password = '' // password for enc file method
//init new Object Model
var item = git.objectModel('item','Init','DB/',password)
// add new object
var add = await item.update_data({name : 'Ravindu',age:'21'})
// + add object
var second_add = await item.update_data({country : 'sri_lanka',age:22,language : 'sinhala'})
// replace new object
var third_add = await item.update_data({game:'cricket',year: 2023},true)
// get data from model
var get_data = await item.get_data()
// delete model
var del = await item.delete_model()
//add
{ name: 'Ravindu', age: '21' }
//second_add
{ name: 'Ravindu', age: 22, country: 'sri_lanka', language: 'sinhala' }
//third_add
{ game: 'cricket', year: 2023 }
//get_data
{ game: 'cricket', year: 2023 }
//del
true
✍️ Authors
- Ravindu Manoj - project author
See also the list of contributors who participated in this project.