A simple ORM to use your Github Repositories as a Database and a Data Bucket with Node.js
- Make CRUD requests on files of your Github Repository
- Use your Github Repository as a Data Bucket
$ npm install gitorm
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)
// Finding a file
const fileName = 'index.txt'
const file = await Gitorm.find({
path: `src/${fileName}`
})
// Finding all files on a directory
const file = await Gitorm.findAll({
path: 'src/'
})
// Creating a file
const fileName = 'index.json'
const fileData = { test: 123 }
const file = await Gitorm.create({
data: JSON.stringify(fileData),
path: `src/${fileName}`
})
// Updating a file
const fileName = 'index.json'
const updatedData = { test: 123 }
const updatedFile = await Gitorm.update({
data: JSON.stringify(updatedData),
path: `src/${fileName}`
})
// Deleting a file
const fileName = 'index.json'
const file = await Gitorm.delete({
path: `src/${fileName}`
})