2.1.5 • Published 2 years ago

ajax.db v2.1.5

Weekly downloads
-
License
GNU GPL3
Repository
github
Last release
2 years ago

@AjaxDB

BeeDB inspired package

Documentation: AjaxDB Docs

Information:

  • :wrench: Efficient and fast database using BSON.
  • :butterfly: Simple and easy to use
  • :smile: Version 2.1

Installation

npm i ajax.db --save

Examples:

  • Create Database & Start Client Instance:
import { Client } from 'ajax.db';

/**
 * @param {object} options - Put database name and path
 * @deprecated Client({ path: string});
 * @new Client({ database: string, path: string });
 * @description Instance new Client for create new database or use a database.
 */
const AjaxDB = new Client({ database: "DatabaseName", path: "path/to/databases" });

/** 
 * @param {string} event - Event name
 * @param {function} callback - Callback function
 * @description The event is emitted when the Client class is instantiated.
*/
AjaxDB.on('start', () => {
  console.log("AjaxDB start!");
});

/** 
 * @param {string} event- Event name
 * @param {function} callback - Callback error.
 * @type {error} ErrorClient interface
 * @description The event is emitted on some conditions of the Database class.
*/
AjaxDB.on('error', (error) => {
  console.error(error);  
});

// Other conditions instantiate the Error clas and stop the database
  • CreatePointer
/** 
 * @param {string} pointer - pointer name
 * @param {string} container - container name
 * @async
 * @description It is recommended to put everything together
*/
await AjaxDB.CreatePointer("PointerName", "ContainerName");
  • push
/** 
 * @param {string} pointer - pointer name
 * @param {object} data - data to push
 * @param {object} AUTO_INCREMENT auto increment id
 * @async
 * @description If AUTO_INCREMENT is true it is not necessary to declare the id, content is required 
*/
await AjaxDB.push("PointerName", { "id": number | string, "content": object }, AUTO_INCREMENT: boolean); 
  • deleteByKey
/** 
 * @param {string} pointer - pointer name
 * @param {string} key - key name
 * @async
 * @description Deletes the data of the specified key and delete key.
*/
await AjaxDB.deleteByKey("PointerName", "KeyName"); // void
  • deleteSeveralByKey Deprecated & Deleted method.
  • get
/**
 * @param {string} pointer - pointer name
 * @param {object} data - find by key
 * @async
 * @description get data of the containers
 * @returns {object}
 * @output { id: number, content: object }
*/
await AjaxDB.get("PointerName", { "KeyName": "KeyValue" });
  • size
/** 
 * @description number of pointers
 * @returns {number}
*/
AjaxDB.size() // OUTPUT: number
  • edit
/** 
 * @param {string} pointer - pointer name
 * @param {object} findKey - key name and key value
 * @param {object} valueKey - key name and key value
 * @async
 * @description edit the data of a key - It is important that in "key" it is declared like this, do not put the name of the key that you want to edit, just leave "key"
 * @deprecated edit("Pointer", "key", value: any);
 * @new edit("Pointer", {"FindKeyName": "ValueKey"}, {"key": "KeyName", "value": "ValueForKey"});
*/

await AjaxDB.edit("PointerName", { "FindKey": "ValueKey" }, { "key": "KeyName", "value": "ValueForKey" }); // void
  • encrypt
/**
 * @param {EncryptOptions} options - Options encrypt data
 * @description Encrypt string data
 * @output {key_encrypted: string, secret_key: string}
 */
const encryptData = AjaxDB.encrypt({ content: string, salt?: number });
  • decrypt
/** 
 * @param {DecryptOptions} options - Options decrypt data
 * @description Decrypt string
 * @output <Crypto-JS>.lib.CipherParams
*/
const decryptedData = AjaxDB.decrypt({ encryptKey: encryptData.key_encrypted.toString(), secretKey: encryptData.secret_key});

Development notes

  • The database is in the testing phase, report any errors.
  • Thanks you for reading!
  • :star: Thanks theMarzon for the inspiration!

Support Discord | My Discord Profile

2.1.5

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.0

2 years ago

1.9.9

2 years ago

1.9.8

2 years ago

1.9.7

2 years ago

1.9.6

2 years ago

1.9.5

2 years ago

1.9.4

2 years ago

1.9.3

2 years ago

1.9.2

2 years ago