Comparing version 1.0.1 to 1.0.2
@@ -1,631 +0,10 @@ | ||
import { EventEmitter } from 'events'; | ||
/** | ||
* Encrypts sensitive data using AES-256-CBC with a random IV. | ||
* @param data The data to encrypt. | ||
* @param secretKey The secret key for encryption (must be 64 bytes long). | ||
* @returns The encrypted data in Base64 format. | ||
*/ | ||
declare function encrypt(data: any, secretKey: string): string; | ||
/** | ||
* Decrypts sensitive data using AES-256-CBC. | ||
* @param encryptedData The encrypted data in Base64 format (including IV). | ||
* @param secretKey The secret key for decryption (must be 64 bytes long). | ||
* @returns The decrypted data. | ||
*/ | ||
declare function decrypt(encryptedData: string, secretKey: string): any; | ||
interface DisplayOptions$1 { | ||
filters?: Record<string, any>; | ||
sortOrder?: "asc" | "desc"; | ||
page: number; | ||
pageSize: number; | ||
displayment?: number | null; | ||
groupBy?: string; | ||
} | ||
interface AdapterUniqueKey { | ||
key: string; | ||
value: any; | ||
} | ||
interface AdapterOptions$1 { | ||
uniqueKeys?: AdapterUniqueKey[]; | ||
} | ||
interface AdapterResults { | ||
acknowledged?: boolean; | ||
message?: string; | ||
errorMessage?: string; | ||
results?: any; | ||
error?: Error; | ||
currentData?: any[]; | ||
} | ||
interface MigrationParams { | ||
from: string; | ||
to: string; | ||
table: string; | ||
} | ||
interface versedbAdapter { | ||
load(dataname: string): Promise<any[]>; | ||
add(dataname: string, newData: any, options?: AdapterOptions$1): Promise<AdapterResults>; | ||
find(dataname: string, query: any): Promise<AdapterResults>; | ||
loadAll(dataname: string, displayOptions: DisplayOptions$1): Promise<AdapterResults>; | ||
remove(dataname: string, query: any, options?: any): Promise<AdapterResults>; | ||
update(dataname: string, queries: any, newData: any, upsert: boolean): Promise<AdapterResults>; | ||
updateMany(dataname: any, queries: any[any], newData: operationKeys$1): Promise<AdapterResults>; | ||
drop(dataname: string): Promise<AdapterResults>; | ||
} | ||
interface SQLAdapter { | ||
load(dataname: string): Promise<AdapterResults>; | ||
createTable(dataname: string, tableName: string, tableDefinition?: string): Promise<AdapterResults>; | ||
insertData(dataname: string, tableName: string, data: any[]): Promise<AdapterResults>; | ||
find(dataname: string, tableName: string, condition?: string): Promise<AdapterResults>; | ||
removeData(dataname: string, tableName: string, dataToRemove: any[]): Promise<AdapterResults>; | ||
update(dataname: string, tableName: string, query: string, newData: any, upsert: boolean): Promise<AdapterResults>; | ||
allData(dataname: string, displayOption: DisplayOptions$1): Promise<AdapterResults>; | ||
updateMany(dataname: string, tableName: string, queries: any[], newData: operationKeys$1): Promise<AdapterResults>; | ||
drop(dataname: string, tableName?: string): Promise<AdapterResults>; | ||
countDoc(dataname: string, tableName: string): Promise<AdapterResults>; | ||
dataSize(dataname: string): Promise<AdapterResults>; | ||
migrateTable({ from, to, table }: MigrationParams): Promise<AdapterResults>; | ||
removeKey(dataname: string, tableName: string, keyToRemove: string, valueToRemove: string): Promise<AdapterResults>; | ||
toJSON(from: string): Promise<AdapterResults>; | ||
} | ||
interface DevLogsOptions$1 { | ||
enable: boolean; | ||
path: string; | ||
} | ||
interface AdapterSetting { | ||
devLogs: DevLogsOptions$1; | ||
} | ||
interface CollectionFilter$1 { | ||
dataname: string; | ||
displayment: number | null; | ||
filter?: any; | ||
} | ||
interface SearchResult { | ||
[key: string]: any[]; | ||
} | ||
interface operationKeys$1 { | ||
$inc?: { | ||
[key: string]: number; | ||
}; | ||
$set?: { | ||
[key: string]: any; | ||
}; | ||
$push?: { | ||
[key: string]: any; | ||
}; | ||
$min?: { | ||
[key: string]: any; | ||
}; | ||
$max?: { | ||
[key: string]: any; | ||
}; | ||
$currentDate?: { | ||
[key: string]: boolean | { | ||
$type: 'date' | 'timestamp'; | ||
}; | ||
}; | ||
upsert?: boolean; | ||
} | ||
interface DevLogsOptions { | ||
enable: boolean; | ||
path: string; | ||
} | ||
interface EncryptionOptions { | ||
enable: boolean; | ||
secret: string; | ||
} | ||
interface BackupOptions { | ||
enable: boolean; | ||
path: string; | ||
password?: string; | ||
retention: number; | ||
} | ||
interface AdapterOptions { | ||
adapter: string; | ||
adapterType?: string | null; | ||
dataPath: string; | ||
devLogs: DevLogsOptions; | ||
encryption: EncryptionOptions; | ||
backup: BackupOptions; | ||
} | ||
interface CollectionFilter { | ||
dataname: string; | ||
displayment: number | null; | ||
filter?: any; | ||
} | ||
interface DisplayOptions { | ||
filters?: Record<string, any>; | ||
sortOrder?: "asc" | "desc"; | ||
page: number; | ||
pageSize: number; | ||
displayment?: number | null; | ||
groupBy?: string; | ||
} | ||
interface operationKeys { | ||
$inc?: { | ||
[key: string]: number; | ||
}; | ||
$set?: { | ||
[key: string]: any; | ||
}; | ||
$push?: { | ||
[key: string]: any; | ||
}; | ||
$min?: { | ||
[key: string]: any; | ||
}; | ||
$max?: { | ||
[key: string]: any; | ||
}; | ||
$currentDate?: { | ||
[key: string]: boolean | { | ||
$type: "date" | "timestamp"; | ||
}; | ||
}; | ||
upsert?: boolean; | ||
} | ||
/** | ||
* Represents the configuration for a field in a data schema. | ||
*/ | ||
interface FieldConfig { | ||
/** | ||
* The data type of the field (e.g., "string", "number", "boolean"). | ||
*/ | ||
type: FieldType; | ||
/** | ||
* Indicates whether the field is required. | ||
*/ | ||
required?: boolean; | ||
/** | ||
* The minimum length of the field (for strings). | ||
*/ | ||
minlength?: number; | ||
/** | ||
* The maximum length of the field (for strings). | ||
*/ | ||
maxlength?: number; | ||
/** | ||
* The minimum value of the field (for numbers). | ||
*/ | ||
min?: number; | ||
/** | ||
* The maximum value of the field (for numbers). | ||
*/ | ||
max?: number; | ||
/** | ||
* Custom validation function for the field. | ||
*/ | ||
validate?: (value: any) => boolean; | ||
/** | ||
* Indicates whether the field value must be unique. | ||
*/ | ||
unique?: boolean; | ||
} | ||
type FieldType = "string" | "number" | "boolean" | "array" | "object" | "null" | "undefined" | "date" | "enum" | "custom" | "union" | "any"; | ||
/** | ||
* Represents a data schema. | ||
*/ | ||
declare class Schema { | ||
/** | ||
* The fields and their configurations in the schema. | ||
*/ | ||
readonly fields: { | ||
[key: string]: FieldConfig; | ||
}; | ||
/** | ||
* Creates an instance of Schema. | ||
* @param fields - The fields and their configurations in the schema. | ||
*/ | ||
constructor(fields: { | ||
[key: string]: FieldConfig; | ||
}); | ||
/** | ||
* Validates data against the schema. | ||
* @param data - The data to validate. | ||
* @param existingData - Optional data to check for uniqueness (if applicable). | ||
* @returns An object containing validation errors, or null if no errors. | ||
*/ | ||
validate(data: { | ||
[key: string]: any; | ||
}, existingData?: any[] | null): { | ||
[key: string]: string; | ||
} | null; | ||
} | ||
declare class jsonAdapter extends EventEmitter implements versedbAdapter { | ||
devLogs: DevLogsOptions$1; | ||
constructor(options: AdapterSetting); | ||
load(dataname: string): Promise<any[]>; | ||
add(dataname: string, newData: any, options?: AdapterOptions$1): Promise<AdapterResults>; | ||
private indexes; | ||
private createIndexesIfNotExists; | ||
find(dataname: string, query: any): Promise<AdapterResults>; | ||
loadAll(dataname: string, displayOptions: any): Promise<AdapterResults>; | ||
remove(dataname: string, query: any, options?: { | ||
docCount: number; | ||
}): Promise<AdapterResults>; | ||
update(dataname: string, query: any, updateQuery: any, upsert?: boolean): Promise<AdapterResults>; | ||
updateMany(dataname: string, query: any, updateQuery: any): Promise<AdapterResults>; | ||
drop(dataname: string): Promise<AdapterResults>; | ||
search(dataPath: string, collectionFilters: CollectionFilter$1[]): Promise<{ | ||
acknowledged: boolean; | ||
message: string; | ||
errorMessage: null; | ||
results: SearchResult; | ||
} | { | ||
acknowledged: boolean; | ||
errorMessage: string; | ||
results: null; | ||
message?: undefined; | ||
}>; | ||
initFile({ dataname }: { | ||
dataname: string; | ||
}): void; | ||
initDir({ dataFolder }: { | ||
dataFolder: string; | ||
}): void; | ||
} | ||
declare class yamlAdapter extends EventEmitter implements versedbAdapter { | ||
devLogs: DevLogsOptions$1; | ||
constructor(options: AdapterSetting); | ||
load(dataname: string): Promise<any[]>; | ||
add(dataname: string, newData: any, options?: AdapterOptions$1): Promise<AdapterResults>; | ||
private indexes; | ||
private createIndexesIfNotExists; | ||
find(dataname: string, query: any): Promise<AdapterResults>; | ||
loadAll(dataname: string, displayOptions: any): Promise<AdapterResults>; | ||
remove(dataname: string, query: any, options?: { | ||
docCount: number; | ||
}): Promise<AdapterResults>; | ||
update(dataname: string, query: any, updateQuery: any, upsert?: boolean): Promise<AdapterResults>; | ||
updateMany(dataname: string, query: any, updateQuery: any): Promise<AdapterResults>; | ||
drop(dataname: string): Promise<AdapterResults>; | ||
search(dataPath: string, collectionFilters: CollectionFilter$1[]): Promise<{ | ||
acknowledged: boolean; | ||
message: string; | ||
errorMessage: null; | ||
results: SearchResult; | ||
} | { | ||
acknowledged: boolean; | ||
errorMessage: string; | ||
results: null; | ||
message?: undefined; | ||
}>; | ||
initFile({ dataname }: { | ||
dataname: string; | ||
}): void; | ||
initDir({ dataFolder }: { | ||
dataFolder: string; | ||
}): void; | ||
} | ||
declare class sqlAdapter extends EventEmitter implements SQLAdapter { | ||
devLogs: DevLogsOptions$1; | ||
constructor(options: AdapterSetting); | ||
load(dataname: string): Promise<AdapterResults>; | ||
createTable(dataname: string, tableName: string, tableDefinition: string): Promise<AdapterResults>; | ||
insertData(dataname: string, tableName: string, data: any[]): Promise<AdapterResults>; | ||
find(dataname: string, tableName: string, condition?: string): Promise<AdapterResults>; | ||
removeData(dataname: string, tableName: string, dataToRemove: any[]): Promise<AdapterResults>; | ||
removeKey(dataname: string, tableName: string, keyToRemove: string): Promise<AdapterResults>; | ||
update(dataname: string, tableName: string, query: any, newData: operationKeys$1): Promise<AdapterResults>; | ||
allData(dataname: string, displayOption: DisplayOptions$1): Promise<AdapterResults>; | ||
updateMany(dataname: string, tableName: string, queries: any[], newData: operationKeys$1): Promise<AdapterResults>; | ||
drop(dataname: string, tableName?: string): Promise<AdapterResults>; | ||
countDoc(dataname: string, tableName: string): Promise<AdapterResults>; | ||
countTable(dataname: string): Promise<AdapterResults>; | ||
dataSize(dataname: string): Promise<AdapterResults>; | ||
migrateTable({ from, to, table, }: MigrationParams): Promise<AdapterResults>; | ||
toJSON(from: string): Promise<AdapterResults>; | ||
private tableExists; | ||
private countDocuments; | ||
private parseSQLToJson; | ||
private parseRowData; | ||
private parseColumnValue; | ||
private generateQueryFromData; | ||
private checkDataMatch; | ||
private extractAllData; | ||
private applyUpdateToRow; | ||
private removeColumnFromRows; | ||
private extractTable; | ||
private writeTableToNewFile; | ||
private countTables; | ||
private removeFullData; | ||
private removeTable; | ||
private executeSelectQuery; | ||
extractRowData(line: string): string | null; | ||
checkQueryMatches(line: string | null, query: any): boolean; | ||
generateNewRow(query: any, newData: operationKeys$1, columns: string[]): string; | ||
findTableIndex(lines: string[], tableName: string): number; | ||
} | ||
/** | ||
* The main connect class for interacting with the database | ||
*/ | ||
declare class connect { | ||
adapter: jsonAdapter | yamlAdapter | sqlAdapter | null; | ||
dataPath: string; | ||
devLogs: DevLogsOptions; | ||
encryption: EncryptionOptions; | ||
backup: BackupOptions; | ||
fileType: string; | ||
/** | ||
* Sets up a database with one of the adapters | ||
* @param {AdapterOptions} options - Options for setting up the adapter | ||
*/ | ||
constructor(options: AdapterOptions); | ||
/** | ||
* Load data from a file | ||
* @param {string} dataname - The name of the data file | ||
* @returns {Promise<any[]>} - A Promise that resolves with the loaded data | ||
*/ | ||
load(dataname: string): Promise<any[] | AdapterResults | undefined>; | ||
/** | ||
* Add data to a data file | ||
* @param {string} dataname - The name of the data file | ||
* @param {any} newData - The new data to add | ||
* @param {object} [options] - Additional options | ||
* @returns {Promise<any>} - A Promise that resolves with the saved data | ||
*/ | ||
add(dataname: string, newData: any, options?: any): Promise<AdapterResults | undefined>; | ||
/** | ||
* @param dataname the data file name | ||
* @param query the search query | ||
* @returns the found data | ||
*/ | ||
find(dataname: string, query: any): Promise<AdapterResults | undefined>; | ||
/** | ||
* | ||
* @param dataname the name of data files to get multiple files in the same time | ||
* @param displayOptions the options of the display of the data files | ||
* @returns all the data files you selected | ||
*/ | ||
loadAll(dataname: string, displayOptions: any): Promise<AdapterResults | undefined>; | ||
/** | ||
* @param dataname the name of the data file you want to edit an item in | ||
* @param query the search query of the item you want to edit | ||
* @param newData the new data that will be edited with the old one | ||
* @param upsert an upsert option | ||
* @returns returnts edited data | ||
*/ | ||
remove(dataname: string, query: any, options: { | ||
docCount: number; | ||
}): Promise<AdapterResults | undefined>; | ||
/** | ||
* edit functions for the data in the database | ||
* @param dataname the name of the data file you want to edit an item in | ||
* @param query the search query of the item you want to edit | ||
* @param newData the new data that will be edited with the old one | ||
* @param upsert an upsert option | ||
* @returns returnts edited data | ||
*/ | ||
update(dataname: string, query: any, newData: any, upsert: boolean): Promise<AdapterResults | undefined>; | ||
/** | ||
* @param dataname the name of the data you want to drop | ||
* @returns empty the file you dropped | ||
*/ | ||
drop(dataname: string): Promise<AdapterResults | undefined>; | ||
/** | ||
* full search method to find in all the database | ||
* @param collectionFilters filters for search in all the database | ||
* @returns search in all the database files | ||
*/ | ||
search(collectionFilters: CollectionFilter[]): Promise<SearchResult | { | ||
acknowledged: boolean; | ||
message: string; | ||
errorMessage: null; | ||
results: SearchResult; | ||
} | { | ||
acknowledged: boolean; | ||
errorMessage: string; | ||
results: null; | ||
message?: undefined; | ||
} | null | undefined>; | ||
/** | ||
* a function to create a new table in SQL database (Note*: this is only supported for SQL adapter) | ||
* @param dataname the name of the data file | ||
* @param tableName the table name | ||
* @param tableDefinition the definition of the table | ||
* @returns new table in the database | ||
*/ | ||
createTable(dataname: string, tableName: string, tableDefinition: string): Promise<AdapterResults | undefined>; | ||
/** | ||
* a function to insert data to a table in the database (Note*: this is only supported for SQL adapter) | ||
* @param dataname the name of the data file | ||
* @param tableName the name of the table you want to insert the data to | ||
* @param data the date that is going to be inserted | ||
* @returns inserted data to the table in the database file | ||
*/ | ||
insertData(dataname: string, tableName: string, data: any[]): Promise<AdapterResults | undefined>; | ||
/** | ||
* a function to find data in a table (Note*: this is only supported for SQL adapter) | ||
* @param dataname the name of the data file | ||
* @param tableName the name of the table to find in | ||
* @param condition the conditions you want to find with | ||
* @returns found data | ||
*/ | ||
findData(dataname: string, tableName: string, condition?: string): Promise<AdapterResults | undefined>; | ||
/** | ||
* a function to remove data from a table (Note*: this is only supported for SQL adapter) | ||
* @param dataname the name of the data file you want to use | ||
* @param tableName the name of the table | ||
* @param dataToRemove the date you want to remove | ||
* @returns removed data from the table | ||
*/ | ||
removeData(dataname: string, tableName: string, dataToRemove: any[]): Promise<AdapterResults | undefined>; | ||
/** | ||
* a fundtion to update the data in the sql database (Note*: this is only supported for SQL adapter) | ||
* @param dataname the name of date file | ||
* @param tableName the table name | ||
* @param query the search query | ||
* @param newData the new data that is going to be replaced with the old data | ||
* @returns updataed data | ||
*/ | ||
updateData(dataname: string, tableName: string, query: any, newData: operationKeys): Promise<AdapterResults | undefined>; | ||
/** | ||
* a function to multi update operation (Note*: this is only supported for SQL adapter) | ||
* @param dataname the data file name you want to update | ||
* @param tableName the tables name | ||
* @param queries the queries you want to search with | ||
* @param newData the new data that is going to be replaced with the old data | ||
* @returns updated data in multiple files or tables | ||
*/ | ||
updateMany(dataname: string, queries: any[], newData: operationKeys): Promise<AdapterResults | undefined>; | ||
/** | ||
* a function to multi update operation (Note*: this is only supported for SQL adapter) | ||
* @param dataname the data file name you want to update | ||
* @param tableName the tables name | ||
* @param queries the queries you want to search with | ||
* @param newData the new data that is going to be replaced with the old data | ||
* @returns updated data in multiple files or tables | ||
*/ | ||
multiUpdate(dataname: string, tableName: string, queries: any[], newData: operationKeys): Promise<AdapterResults | undefined>; | ||
/** | ||
* a function to display all the data in the sql adapter database (Note*: this is only supported for SQL adapter) | ||
* @param dataname the date names you want to display | ||
* @param displayOption the display options you want to display | ||
* @returns all the data you want to display | ||
*/ | ||
displayAll(dataname: string, displayOption: DisplayOptions): Promise<AdapterResults | undefined>; | ||
/** | ||
* a function to drop data ot a table (Note*: this is only supported for SQL adapter) | ||
* @param dataname the data file name you want to drop | ||
* @param tableName the table name you want to drop | ||
* @returns droped data | ||
*/ | ||
dropData(dataname: string, tableName?: string): Promise<AdapterResults | undefined>; | ||
/** | ||
* a function to count the data documents in the database (Note*: this is only supported for SQL adapter) | ||
* @param dataname the data file name | ||
* @param tableName the table name | ||
* @returns documents count | ||
*/ | ||
countDoc(dataname: string, tableName: string): Promise<AdapterResults | undefined>; | ||
/** | ||
* a function to give you the count of the tables in the dataname file (Note*: this is only supported for SQL adapter) | ||
* @param dataname the data file name you want to get the number of the tables in | ||
* @returns number of the tables in the dataname | ||
*/ | ||
countTable(dataname: string): Promise<AdapterResults | undefined>; | ||
/** | ||
* a function to give you the size of the database (Note*: this is only supported for SQL adapter) | ||
* @param dataname the data file name to get the size of | ||
* @returns the size of the data file | ||
*/ | ||
dataSize(dataname: string): Promise<AdapterResults | undefined>; | ||
/** | ||
* a funciton to remove a key from the database table (Note*: this is only supported for SQL adapter) | ||
* @param dataname the data file name | ||
* @param tableName the table name | ||
* @param keyToRemove the key you want to remove | ||
* @returns removed key | ||
*/ | ||
removeKey(dataname: string, tableName: string, keyToRemove: string): Promise<AdapterResults | undefined>; | ||
/** | ||
* | ||
* @param dataname the data file name you want (Note*: this is only supported for SQL adapter) | ||
* @param tableName the table name you want | ||
* @param keyToRemove the key to remove | ||
* @returns removed key | ||
*/ | ||
toJSON(dataname: string, tableName: string, keyToRemove: string): Promise<AdapterResults | undefined>; | ||
/** | ||
* a function to move a table from a database to another database file (Note*: this is only supported for SQL adapter) | ||
* @param {from} from the dataname | ||
* @param {to} to the dataname | ||
* @param {table} the table you want to move | ||
* @returns moved table | ||
*/ | ||
moveTable({ from, to, table, }: { | ||
from: string; | ||
to: string; | ||
table: string; | ||
}): Promise<AdapterResults | undefined>; | ||
/** | ||
* a funciton to get the info of a json/yaml file | ||
* @param {dataname} options an option to get the info of a supusfic data file | ||
* @returns | ||
*/ | ||
info(options: { | ||
dataname?: string; | ||
}): Promise<AdapterResults>; | ||
/** | ||
* a funciton to get the number of objects in a file | ||
* @param {dataname} the name of the data you want to get the number of the objects inside it | ||
* @param {query} an optional query to get the number of the objects that only contains this query | ||
* @returns number of objects in a file | ||
*/ | ||
countDocuments({ dataname, query, }: { | ||
dataname: string; | ||
query?: { | ||
[key: string]: string; | ||
}; | ||
}): Promise<AdapterResults>; | ||
/** | ||
* @param dataname the schema name | ||
* @param schema the schema defination | ||
* @returns {add} to add data to the database | ||
* @returns {remove} to remove data to the database | ||
* @returns {update} to update data from the database | ||
* @returns {find} to find data in the database | ||
* @returns {load} to load a database | ||
* @returns {drop} to drop a database | ||
*/ | ||
model(dataname: string, schema: Schema): any; | ||
} | ||
/** | ||
* Generates a random ID. | ||
* @returns A random ID string. | ||
*/ | ||
declare function randomID(): string; | ||
/** | ||
* Generates a random UUID. | ||
* @returns A random UUID string. | ||
*/ | ||
declare function randomUUID(): string; | ||
type logsPath = string; | ||
/** | ||
* @param content the content to log error it | ||
*/ | ||
declare function logError({ content, throwErr, devLogs, }: { | ||
content: any; | ||
throwErr?: boolean; | ||
devLogs?: DevLogsOptions; | ||
}): void; | ||
/** | ||
* @param content the content to log success it | ||
*/ | ||
declare function logSuccess({ content, devLogs, }: { | ||
content: any; | ||
devLogs?: DevLogsOptions; | ||
logsPath?: logsPath; | ||
}): void; | ||
/** | ||
* @param content the content to log warning it | ||
*/ | ||
declare function logWarning({ content, devLogs, }: { | ||
content: any; | ||
devLogs?: DevLogsOptions; | ||
logsPath?: logsPath; | ||
}): void; | ||
/** | ||
* @param content the content to log Info it | ||
*/ | ||
declare function logInfo({ content, devLogs, }: { | ||
content: any; | ||
devLogs?: DevLogsOptions; | ||
logsPath?: logsPath; | ||
}): void; | ||
/** | ||
* @params Copyright(c) 2023 marco5dev & elias79 & kmoshax | ||
* MIT Licensed | ||
*/ | ||
import { encrypt, decrypt } from "./core/encription"; | ||
import connect from "./core/connect"; | ||
import { randomID, randomUUID } from "./lib/id"; | ||
import { logError, logInfo, logSuccess, logWarning } from "./core/logger"; | ||
import Schema from "./core/schema"; | ||
declare const logger: { | ||
@@ -651,3 +30,3 @@ logError: typeof logError; | ||
}; | ||
export { Schema, connect, decrypt, versedb as default, encrypt, logger, randomID, randomUUID }; | ||
export { connect, encrypt, decrypt, randomID, randomUUID, logger, Schema }; | ||
export default versedb; |
{ | ||
"name": "verse.db", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "verse.db isn't just a database, it's your universal data bridge. Designed for unmatched flexibility, security, and performance, verse.db empowers you to manage your data with ease.", | ||
@@ -28,3 +28,3 @@ "license": "MIT", | ||
"scripts": { | ||
"build": "tsup", | ||
"build": "tsc", | ||
"test": "jest" | ||
@@ -39,5 +39,5 @@ }, | ||
"ts-jest": "^29.1.2", | ||
"ts-node": "^10.9.2", | ||
"tsup": "^8.0.2", | ||
"typescript": "^5.4.2", | ||
"ts-node": "^10.9.2" | ||
"typescript": "^5.4.2" | ||
}, | ||
@@ -44,0 +44,0 @@ "dependencies": { |
110
README.md
@@ -25,2 +25,4 @@ # verse.db | ||
yarn add verse.db | ||
pnpm add verse.db | ||
bun add verse.db | ||
``` | ||
@@ -32,15 +34,17 @@ | ||
to get started setup the database connection uding .connect method | ||
- to get started setup the database connection uding .connect method | ||
<details> | ||
```javascript | ||
const versedb = require("verse.db"); | ||
const versedb = require("verse.db"); // JS or CJS module | ||
// or | ||
import versedb from "verse.db"; | ||
import versedb from "verse.db"; // TS or ES module | ||
const adapterOptions = { | ||
adapter: "json" | "yaml" | "sql", // the type of the adapter json, yaml or sql | ||
dataPath: "./Data", // the path of the data folder | ||
devLogs: { enable: true, path: "./Logs" }, // the path to the logs folder | ||
encryption: { enable: false, secret: "" }, // Under Development: Encryption option | ||
backup: { enable: false, path: "", retention: 0 }, // Under Development: Backing up | ||
adapter: "json" | "yaml" | "sql", // Type of the Database to use | ||
dataPath: "./Data", // Path to the databse folder | ||
devLogs: { enable: true, path: "./Logs" }, // Logs of database events | ||
encryption: { enable: false, secret: "" }, // Under Maintenance | ||
backup: { enable: false, path: "", retention: 0 }, // Under Maintenance | ||
}; | ||
@@ -51,10 +55,15 @@ | ||
Note\*: that you can make a multiple databases in the same time with/without the same extention | ||
</details> | ||
Note\*: You can make a multiple database files in the same time with/without the same intializer | ||
### Load a data file | ||
You can load any data file using .load method | ||
- You can load any data file using .load method | ||
<details> | ||
```javascript | ||
const dataname = "data"; // the name of the datafile without the extention | ||
const dataname = "data"; // The name of the file of the database | ||
const result = await db.load(dataname); | ||
@@ -65,6 +74,11 @@ | ||
</details> | ||
### Add Data | ||
To add data, use the .add method, for example: | ||
- To add data, use the .add method, for example: | ||
<details> | ||
```javascript | ||
@@ -76,3 +90,3 @@ // Arrange | ||
]; | ||
const dataname = "dataFileName"; | ||
const dataname = "users"; | ||
@@ -83,2 +97,3 @@ // Act | ||
result: | ||
@@ -90,13 +105,15 @@ | ||
"message": "Data added successfully.", | ||
"results": [ | ||
{ "_id": "1234", "name": "John" }, | ||
{ "_id": "5678", "name": "Jane" } | ||
] | ||
} | ||
``` | ||
</details> | ||
### find data | ||
Find the data you want with the query you want using .find method: | ||
- Find the data you want with the query you want using .find method: | ||
<details> | ||
```javascript | ||
@@ -109,3 +126,3 @@ // Arrange | ||
const query = { name: "John" }; | ||
const dataname = "dataFileName"; | ||
const dataname = "users"; | ||
@@ -123,6 +140,12 @@ // Act | ||
</details> | ||
### Remove data | ||
Remove the data you want with the query you want using .remove method: | ||
- Remove the data you want with the query you want using .remove method: | ||
<details> | ||
```javascript | ||
@@ -135,3 +158,3 @@ // Arrange | ||
const query = { _id: "1234" }; | ||
const dataname = "remove"; | ||
const dataname = "users"; | ||
@@ -149,6 +172,12 @@ // Act | ||
</details> | ||
### Update | ||
Update the data you want with the query you want using .update method: | ||
- Update the data you want with the query you want using .update method: | ||
<details> | ||
```javascript | ||
@@ -161,4 +190,29 @@ // Arrange | ||
const updateQuery = { $set: { name: "Mike" } }; | ||
const dataname = "update"; | ||
const dataname = "users"; | ||
// Valid operation Kyes | ||
/* | ||
- $set: Modifies an existing field's value or adds a new field if it doesn't exist. | ||
- $unset: Deletes a particular field. | ||
- $inc: Increments the value of a field by a specified amount. | ||
- $currentDate: Sets the value of a field to the current date, either as a Date or a Timestamp. | ||
- $push: Adds an element to an array. | ||
- $pull: Removes all array elements that match a specified query. | ||
- $position: Modifies the $push operator to specify the position in the array to add elements. | ||
- $max: Updates the value of the field to the specified value if the specified value is greater than the current value. | ||
- $min: Updates the value of the field to the specified value if the specified value is less than the current value. | ||
- $or: Performs a logical OR operation on an array of two or more query expressions. | ||
- $addToSet: Adds elements to an array only if they do not already exist in the set. | ||
- $pushAll: Adds multiple values to an array. | ||
- $pop: Removes the first or last element of an array. | ||
- $pullAll: Removes all occurrences of specified values from an array. | ||
- $rename: Renames a field. | ||
- $bit: Performs bitwise AND, OR, and XOR updates of integer values. | ||
- $mul: Multiplies the value of a field by a specified amount. | ||
- $each: Modifies the $push and $addToSet operators to append multiple values to an array. | ||
- $slice: Limits the number of elements in an array that matches the query condition. | ||
- $sort: Orders the elements of an array. | ||
*/ | ||
// Act | ||
@@ -178,6 +232,12 @@ const result = await db.update(dataname, { name: "John" }, updateQuery); | ||
### | ||
</details> | ||
## For Further Usages (Other Adapters And Functions) | ||
- Kindly Note: We provide here a very small sample for usage for JSON for further usage and information. Check out on our [website](https://versedb.jedi-studio.com) | ||
- For Support And Help: Visit us on our discord server. [Link](https://discord.gg/mDyXV9hzXw) | ||
## Conclusion | ||
The verse.db package simplifies the management of JSON data files within a specified folder. With the provided examples and usage instructions, you'll be able to efficiently integrate the verse.db package into your projects to streamline data operations. | ||
Verse.db stands as a cutting-edge database management platform engineered to effortlessly handle JSON, YAML, and SQL data formats. While presently we don't provide server hosting for user data, rest assured, it's on our roadmap and will soon become a reality. Furthermore, we're dedicated to broadening our support for diverse data formats, ensuring we meet and exceed your evolving needs and expectations. Stay tuned for an even more feature-rich experience! |
@@ -5,10 +5,9 @@ # Security Policy | ||
We are currently supporting the following versions of the `jsonverse` package: | ||
We are currently supporting the following versions of the `verse.db` package: | ||
- 1.0.0 to 1.3.3 | ||
- 2.0.0 (now) | ||
- 1.0 (now) | ||
## Reporting a Vulnerability | ||
If you discover a security vulnerability within the `jsonverse` package, please send an email to marco5dev@outlook.com. All security vulnerabilities will be promptly addressed. | ||
If you discover a security vulnerability within the `verse.db` package, please send an email to marco5dev@outlook.com. All security vulnerabilities will be promptly addressed. | ||
@@ -33,2 +32,2 @@ Please do not open GitHub issues for security vulnerabilities. | ||
Thank you for using the `jsonverse` package. Your security is our priority. | ||
Thank you for using the `verse.db` package. Your security is our priority. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Obfuscated code
Supply chain riskObfuscated files are intentionally packed to hide their behavior. This could be a sign of malware.
Found 2 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
2066243
54
16163
230
6
26