Comparing version 1.1.7 to 1.1.8
166
index.js
@@ -1,62 +0,130 @@ | ||
const adapters = [ "YamlDB", "JsonDB"] | ||
class efDB { | ||
constructor(ayarlar={}) { | ||
this.options = ayarlar | ||
this.adapter = ayarlar["adapter"] ? (adapters.includes(ayarlar["adapter"]) ? ayarlar["adapter"] : "JsonDB") : "JsonDB"; | ||
this.dataName = ayarlar["dataName"] ? ayarlar["dataName"] : "efDB" | ||
this.dataFolder = ayarlar["dataFolder"] ? ayarlar["dataFolder"] : "efDB" | ||
const adapterr = require(`./adapters/${this.adapter}`) | ||
this.efdb = new adapterr({ | ||
adapter:this.adapter, | ||
dataName:this.dataName, | ||
dataFolder:this.dataFolder | ||
}) | ||
this.set = this.constructor.set; | ||
this.get = this.constructor.get; | ||
this.fetch = this.constructor.fetch; | ||
this.add = this.constructor.add; | ||
this.has = this.constructor.has; | ||
this.subtract = this.constructor.subtract; | ||
this.push = this.constructor.push; | ||
this.unpush = this.constructor.unpush; | ||
this.all = this.constructor.all; | ||
this.deleteAll = this.constructor.deleteAll; | ||
this.delete = this.constructor.delete; | ||
const { isValidValue } = require("./util"); | ||
class Database { | ||
constructor(options) { | ||
if (options.adapter.toLowerCase() == "jsondb") { | ||
let JSONDatabase = require("./databases/JsonDB"); | ||
this.database = new JSONDatabase(options); | ||
}else if(options.adapter.toLowerCase() == "yamldb") { | ||
let YAMLDatabase = require("./databases/YamlDB"); | ||
this.database = new YAMLDatabase(options); | ||
}else throw new Error("You must specify the database.") | ||
} | ||
static set(data, key) { | ||
return this.efdb.set(data, key) | ||
set(key, value) { | ||
if (typeof key == "undefined") throw new TypeError("\"key\" parameter must be available."); | ||
if (typeof key != "string") throw new TypeError("\"key\" parameter must be String."); | ||
if (typeof value == "undefined") throw new TypeError("\"value\" parameter must be available."); | ||
if (!isValidValue(value)) throw new TypeError("\"value\" parameter must be String or Number or Boolean or Object or Array."); | ||
this.database.set(key, value); | ||
return this.database.get(key); | ||
} | ||
static has(data) { | ||
return this.efdb.has(data) | ||
delete(key) { | ||
if (typeof key == "undefined") throw new TypeError("\"key\" parameter must be available."); | ||
if (typeof key != "string") throw new TypeError("\"key\" parameter must be String."); | ||
this.database.delete(key); | ||
return true; | ||
} | ||
static get(data) { | ||
return this.efdb.get(data) | ||
all() { | ||
return this.database.all(); | ||
} | ||
static fetch(data) { | ||
return this.efdb.get(data) | ||
get(key) { | ||
if (typeof key == "undefined") throw new TypeError("\"key\" parameter must be available."); | ||
if (typeof key != "string") throw new TypeError("\"key\" parameter must be String."); | ||
return this.database.get(key); | ||
} | ||
static add(data, number) { | ||
return this.efdb.add(data, number) | ||
has(key) { | ||
if (typeof key == "undefined") throw new TypeError("\"key\" parameter must be available."); | ||
if (typeof key != "string") throw new TypeError("\"key\" parameter must be String."); | ||
return this.database.has(key); | ||
} | ||
static subtract(data, number) { | ||
return this.efdb.subtract(data, number) | ||
fetch(key) { | ||
return this.get(key); | ||
} | ||
static push(data, key) { | ||
return this.efdb.push(data, key) | ||
push(key, value) { | ||
if (typeof key == "undefined") throw new TypeError("\"key\" parameter must be available."); | ||
if (typeof key != "string") throw new TypeError("\"key\" parameter must be String."); | ||
if (typeof value == "undefined") throw new TypeError("\"value\" parameter must be available."); | ||
if (!isValidValue(value)) throw new TypeError("\"value\" parameter must be String or Number or Boolean or Object or Array."); | ||
if ((this.database.has(key) == false) && (this.database.ignoreWarns == false)) console.warn("This data isn't available. Created new array to this data."); | ||
if (this.database.has(key) == false) this.database.set(key, []); | ||
let data = this.database.get(key); | ||
if (!Array.isArray(data)) throw new TypeError("This data isn't Array so couldn't pushed value to this data."); | ||
data.push(value); | ||
this.database.set(key, data) | ||
return data; | ||
} | ||
static unpush(data, key) { | ||
return this.efdb.unpush(data, key) | ||
unpush(key, value) { | ||
if (typeof key == "undefined") throw new TypeError("\"key\" parameter must be available."); | ||
if (typeof key != "string") throw new TypeError("\"key\" parameter must be String."); | ||
if (typeof value == "undefined") throw new TypeError("\"value\" parameter must be available."); | ||
if (!isValidValue(value)) throw new TypeError("\"value\" parameter must be String or Number or Boolean or Object or Array."); | ||
if ((this.database.has(key) == false) && (this.database.ignoreWarns == false)) console.warn("This data isn't available. Created new array to this data."); | ||
if (this.database.has(key) == false) this.database.set(key, []); | ||
if (!Array.isArray(this.database.get(key))) throw new TypeError("This data isn't Array so couldn't pushed value to this data."); | ||
this.database.set(key, this.database.get(key).filter(k => k != value)) | ||
return this.database.get(key); | ||
} | ||
static all() { | ||
return this.efdb.all() | ||
add(key, value) { | ||
if (typeof key == "undefined") throw new TypeError("\"key\" parameter must be available."); | ||
if (typeof key != "string") throw new TypeError("\"key\" parameter must be String."); | ||
if (typeof value == "undefined") throw new TypeError("\"value\" parameter must be available."); | ||
if (typeof value != "number") throw new TypeError("\"value\" parameter must be Number."); | ||
if ((this.database.has(key) == false) && (this.database.ignoreWarns == false)) console.warn("This data isn't available. The data to be added is received as 0."); | ||
if (this.database.has(key) == false) this.database.set(key, 0); | ||
let data = this.database.get(key); | ||
this.database.set(key, (data + value)); | ||
data = this.database.get(key); | ||
return data; | ||
} | ||
static delete(data) { | ||
return this.efdb.delete(data) | ||
subtract(key, value) { | ||
if (typeof key == "undefined") throw new TypeError("\"key\" parameter must be available."); | ||
if (typeof key != "string") throw new TypeError("\"key\" parameter must be String."); | ||
if (typeof value == "undefined") throw new TypeError("\"value\" parameter must be available."); | ||
if (typeof value != "number") throw new TypeError("\"value\" parameter must be Number."); | ||
if ((this.database.has(key) == false) && (this.database.ignoreWarns == false)) console.warn("This data isn't available. The data to be subtracted is received as 0."); | ||
if (this.database.has(key) == false) this.database.set(key, 0); | ||
let data = this.database.get(key); | ||
this.database.set(key, (data - value)); | ||
data = this.database.get(key); | ||
return data; | ||
} | ||
static deleteAll() { | ||
return this.efdb.deleteAll() | ||
substract(key, value) { | ||
return this.subtract(key, value); | ||
} | ||
} | ||
module.exports = efDB | ||
module.exports.version = "1.1.7" | ||
module.exports.destek = "https://discord.gg/umXR2mspNx" | ||
module.exports = Database; |
{ | ||
"name": "efdb", | ||
"version": "1.1.7", | ||
"description": "Türkçe basit JsonDB YamlDB veritabanı modülü", | ||
"version": "1.1.8", | ||
"description": "A database handler, Supports Jsondb, YamlDB.", | ||
"main": "index.js", | ||
@@ -9,9 +9,2 @@ "scripts": { | ||
}, | ||
"author": "null.man", | ||
"license": "ISC", | ||
"dependencies": { | ||
"fs": "0.0.1-security", | ||
"lowdb": "^1.0.0" | ||
}, | ||
"devDependencies": {}, | ||
"repository": { | ||
@@ -22,14 +15,20 @@ "type": "git", | ||
"keywords": [ | ||
"yamldb", | ||
"jsondb", | ||
"database", | ||
"efdb", | ||
"yaml", | ||
"json", | ||
"nullman", | ||
"turkish" | ||
"eftools", | ||
"database", | ||
"jsondatabase", | ||
"yamldatabase" | ||
], | ||
"author": "null.man", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/NulIMan/efdb/issues" | ||
}, | ||
"homepage": "https://github.com/NulIMan/efdb#readme" | ||
"homepage": "https://github.com/NulIMan/efdb#readme", | ||
"dependencies": { | ||
"eftools": "^1.0.2", | ||
"fs": "0.0.1-security" | ||
} | ||
} |
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
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
Network access
Supply chain riskThis module accesses the network.
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
16702
43
2
292
+ Addedeftools@^1.0.2
+ Addedaxios@0.21.4(transitive)
+ Addedefdb@1.1.9(transitive)
+ Addedeftools@1.0.3(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
- Removedlowdb@^1.0.0
- Removedgraceful-fs@4.2.11(transitive)
- Removedis-promise@2.2.2(transitive)
- Removedlodash@4.17.21(transitive)
- Removedlowdb@1.0.0(transitive)
- Removedpify@3.0.0(transitive)
- Removedsteno@0.4.4(transitive)