LocaleDb can Convert Your Locale Project Storage Into a Database
npm install localedb
let localeDb = require("localedb");
Most of Functions are Promised Based So be aware to use it outside of async Functions.
let conn = await localeDb.createDB("MyDatabase");
-
localeDb.createDB(dbName)
Creates Database In our Project Folder. -
dbName
takes String of Database Name You want to Create. - Returns Connections Object.
let conn = await localeDb.ConnectDb("MyDatabase");
-
localeDb.ConnectDb(dbName)
Connect to the Database. -
dbName
takes String of Database Name You want to Connect. - Returns Conection Object.
await localeDb.deleteDB("MyDatabase");
-
localeDb.deleteDB(dbName)
Delete The Database. - Returns
LocaleDBPromiseDefaultResponse
await localeDb.isDBExists("MyDatabase");
-
localeDb.isDBExists(dbName)
Checks if Database Exists or Not. - Returns
boolean
.
Db Connection Object
Can Be Accessed by localeDb.ConnectDb(dbName)
.
let conn = await localeDb.Connect(dbName);
- Returns
Db Connection Object
await conn.getDbInfo();
- Returns
JSON
Object Containing Database Information.
await conn.createStage(stageName);
- Takes
stageName
argument as the Name of the Stage Inside The Database. - Returns
Stage Connection Object
.
let stage = await conn.ConnectStage(stageName);
- Creates Stage if Does not Exists.
- Returns
Stage Connection Object
.
await conn.isStageExists(stageName);
- Returns
boolean
.
await conn.deleteStage(stageName)
- Returns
LocaleDBPromiseDefaultResponse
.
Stage Connection Object
Can Be Accessed by conn.ConnectStage(stageName)
.
let stage = await conn.ConnectStage(stageName);
- Returns
Stage Connection Object
await stage.getDbInfo();
- Returns
JSON
Object Containing Database Info.
await stage.getStageInfo();
- Returns
JSON
Object Containing Stage Info.
await stage.addData(data);
- Takes
JSON
Object. - Automatically Add
dataId
Key If Not Provided to Given Data and Value Will be Unique. - Returns
LocaleDBPromiseDefaultResponse
Object.
await stage.getAllData();
- Returns
LocaleDBPromiseDefaultResponse
Containingresult
Array Of Data.
await stage.getDataById(dataId);
- Takes
dataId
as the Unique Key Generated/Provided While Adding Data. - Returns Single Object Or Array Of Object Containing Provided
dataId
.
await stage.deleteDataById(dataId);
- Returns Arrary Of Deleted Data.
await stage.clear();
- Returns
LocaleDBPromiseDefaultResponse
Object.
await stage.updateDataById(dataId, data);
- Takes Second Argument As the Data You Want to Update.
- Returns
LocaleDBPromiseDefaultResponse
Object Containingupdated
Array Insideresult
Object.
await stage.updateData(compareData, updateData);
- Takes
compareData
As the Keys You Want to Compare with All Data - If
data
matchescompareData
's Keys and it Values, The Keys ofdata
Will be Updated/Added todata
Corresponding to the Keys ofupdateData
.