Small library that allows you to work with json files as with database.
Using npm:
$ npm i -g npm
$ npm i jdatabaseTo create an DB instance use:
const {DataBase} = require('jdatabase');
const MyDataBase = new DataBase(DBOptions)
MyDataBase.init();
getSchemes(): string[]- returns the list of schemes namesgetScheme(schemeName: string): SchemeInterface- return the scheme instance by scheme name
getTables(): string[]- returns the list of tables namesgetTable(tableName: string): TableInterface- returns the table instance by table name
getFields(): TableFieldData[]- returns the list of table fieldsgetData(): TableDataItem[]- returns the table datainsertItem(itemToInsert: TableDataItem): TableDataItem[]- sets the new item and return list of all itemsupdateItem(itemToUpdate: TableDataItem): TableDataItem[]- updates passed item and return list of all itemsdeleteItem(itemToDelete: TableDataItem): TableDataItem[]- removes the item and return list of all items
You allowed use migrations to easily setup database and seed some data.
To use migrations do:
const {Migrate} = require('jdatabase');
const MyMigration = new Migrate(MigrateOptions)
MyMigration.migrate()
To use seeder do:
const {Seeder} = require('jdatabase');
const MySeeder = new Seeder(SeederOptions)
MySeeder.seed()
All the data instances are described in interfaces