1.4.0 • Published 1 year ago
kio-database v1.4.0
Installing
Just installing module
$ npm install kio-databаse
Quick start
Creating file with .kiod extention
import { KioDatabase } from 'kio-database'
const kd = new KioDatabase('example.kiod')
Adding table columns
kd.addColumn('id', 'number', {
unique: true
})
// or multi-adding columns
kd.addColumns([
{
name: 'id',
type: 'number',
unique: true
}, {
name: 'name',
type: 'string',
defaultValue: 'No Name'
}, {
name: 'surname'
}
])
Insert, update and delete data from table
// inserting into table
kd.insert({
id: 12345,
name: 'Kio',
surname: 'gia'
})
// updating columns where "id" == 12345
kd.update({
surname: 'Gia'
}, {
column: 'id',
operand: 12345
})
// delete columns where "name" != Kio
kd.delete({
column: 'name',
operator: '!=',
operand: 'Kio'
})
Getting data
// selecting rows where "name" == Kio
kd.select({
column: 'name',
operand: 'Kio'
})
// returns []
// selecting rows where unique column "id" == 12345
kd.selectByUnique({
column: 'id',
operand: 12345
})
// returns {} or undefined
// or selecting first match where column "name" == 'Kio'
kd.selectFirst({
column: 'name',
operand: 'Kio'
})
// returns {} or undefined
// forEach loop
kd.forEach((row, rowIndex, rows) => {
// some script
})
// or select all rows
kd.getAll
// returns []
// amd selecting all column cells
kd.selectColumnCells('name')
// returns []
Table visualize with markdown file
kd.toFile('my-database.md')