gitorm
v0.0.25
Published
A simple ORM to use your Github Repositories as a Database and a Data Bucket with Node.js
Downloads
699
Maintainers
Readme
gitorm
A simple ORM to use your Github Repositories as a Database and a Data Bucket with Node.js
Features
- Make CRUD requests on files of your Github Repository
- Use your Github Repository as a Data Bucket
Installing
$ npm install gitorm
Getting started
gitorm(config)
To use Gitorm, you'll need to generate a token with repo and user scopes on Github Developer Settings.
// Creating a connection
import gitorm from 'gitorm'
const Gitorm = new gitorm({
token: 'generated-token',
repository: 'repo-name',
owner: 'repo-owner'
})
await Gitorm.connect()
console.log(Gitorm.status)
gitorm.find(options)
// Finding a file
const fileName = 'index.txt'
const file = await Gitorm.find({
path: `src/${fileName}`
})
gitorm.findAll(options)
// Finding all files on a directory
const file = await Gitorm.findAll({
path: 'src/'
})
gitorm.create(options)
// Creating a file
const fileName = 'index.json'
const fileData = { test: 123 }
const file = await Gitorm.create({
data: JSON.stringify(fileData),
path: `src/${fileName}`
})
gitorm.update(options)
// Updating a file
const fileName = 'index.json'
const updatedData = { test: 123 }
const updatedFile = await Gitorm.update({
data: JSON.stringify(updatedData),
path: `src/${fileName}`
})
gitorm.delete(options)
// Deleting a file
const fileName = 'index.json'
const file = await Gitorm.delete({
path: `src/${fileName}`
})