easysqlite v1.3.3
A simple SQLITE/SQLITE3 Wrapper for People who are new To Coding and maybe Experienced ones to make SQLITE Easier and to Handle Databases Easier!
Usage
Note: The module must be Installed first, before use.
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
options | Object | ✓ | none | Options for the Database Name and File Name |
options.name | String | ✓ | 'database' | Sets the Database Name and File Name |
options.arrname | String | ✓ | 'database_array' | Sets the Database Array Name and Array File Name |
options.objname | String | ✓ | 'database_object' | Sets the Database Object Name and Object File Name |
open
const EasySqlite = require('easysqlite'); // Require the Package
const db = new EasySqlite(); // Make a new Constructor with options
db.open('1234567890').then(i => { // Gets the Information on the Database of ID: 1234567890
console.log(i); // Returns { id: '1234567890', value: 0, text: '' }
});
Returns Promise[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
updateText
const EasySqlite = require('easysqlite'); // Require the Package
const db = new EasySqlite(); // Make a new Constructor with options
db.updateText('1234567890', 'Hello!').then(i => { // Updates the text of id: 1234567890
console.log(i); // Returns { id: '1234567890', value: 0, text: 'Hello!' }
});
Returns Promise[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
updateValue
const EasySqlite = require('easysqlite'); // Require the Package
const db = new EasySqlite(); // Make a new Constructor with options
db.updateValue('1234567890', 20).then(i => { // Adds 20 to the Value of id: 1234567890
console.log(i); // Returns { id: '1234567890', value: 20, text: ' }
});
Returns Promise[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
fetchArray
const EasySqlite = require('easysqlite'); // Require the Package
const db = new EasySqlite(); // Make a new Constructor with options
db.fetchArray('1234567890').then(i => { // Fetches the Array of ID: '1234567890'
console.log(i); // Returns an Empty Array []
});
Returns Promise[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
setArray
const EasySqlite = require('easysqlite'); // Require the Package
const db = new EasySqlite(); // Make a new Constructor with options
db.setArray('1234567890', ['Hello', 'Hi!']).then(i => { // Adds the Array to the ID: 1234567890
console.log(i); // Returns the Array ['Hello', 'Hi!']
// Take Note: If there is an item in the elements, ( e.g 3rd element has 'XD' ) it will replace it
});
Returns Promise[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
fetchObject
const EasySqlite = require('easysqlite'); // Require the Package
const db = new EasySqlite(); // Make a new Constructor with options
db.fetchObject('12345').then(i => {
console.log(i); // Returns: { id: '12345', obj: {} }
});
Returns Promise[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
setObject
const EasySqlite = require('easysqlite'); // Require the Package
const db = new EasySqlite(); // Make a new Constructor with options
db.setObject('12345', { a_key: 'a_value' }).then(i => {
console.log(i); // Returns: { id: '12345', obj: { a_key: 'a_value' } }
});
Returns Promise[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
What's New in 1.3.3?
- We have added a workaround for the manual
JSON.parse()
at your code - Instead of null on empty object at
fetchObject()
it will just return an empty object - Fixed where, when you add the File Name options, it doesn't set it
- New Owner,
kevlarfromdiscord
Have any Problems?
Join Here for us to resolve your Problems!