Giter Club home page Giter Club logo

quick.db's Introduction

Quick.db Logo

Need a powerful, low-cost VPS for hosting your applications & bots 24/7? Check out our partner, Contabo! 🎉

Auto Generated Docs docs
Guide Guide
Support: discord.gg/plexidev
NPM: npmjs.com/quick.db

Quick.db is an open-source package meant to provide an easy way for beginners and people of all levels to access & store data in a low to medium volume environment. All data is stored persistently via either better-sqlite3, mysql2, pg or mongoose and comes way various other quality-of-life features.

  • Persistent Storage - Data doesn't disappear through restarts
  • Multiple Drivers - SQLite, MySQL, Postgres, Mongoose
  • Works out of the box - No need to set up a database server, all the data is stored locally in the same project
  • Beginner Friendly - Originally created for use in tutorials, the documentation is straightforward and jargon-free
  • & more...

If you want to support me

"Buy Me A Coffee"

Installation

npm i quick.db

Mac Prerequisites
1. Install XCode
2. Run `npm i -g node-gyp` in terminal
3. Run `node-gyp --python /path/to/python` in terminal

If you're having troubles installing, please follow this troubleshooting guide. Windows users may need to do additional steps listed here.

Example With Sqlite (Default driver)

NOTE: In order to use this driver, install npm i better-sqlite3 separately.

const { QuickDB } = require("quick.db");
const db = new QuickDB(); // will make a json.sqlite in the root folder
// if you want to specify a path you can do so like this
// const db = new QuickDB({ filePath: "source/to/path/test.sqlite" });

(async () => {
    // Init the database, this is always needed!
    await db.init();

    // self calling async function just to get async
    // Setting an object in the database:
    await db.set("userInfo", { difficulty: "Easy" });
    // -> { difficulty: 'Easy' }

    // Getting an object from the database:
    await db.get("userInfo");
    // -> { difficulty: 'Easy' }

    // Getting an object property from the database:
    await db.get("userInfo.difficulty");
    // -> 'Easy'

    // Setting an object in the database:
    await db.set("userInfo", { difficulty: "Easy" });
    // -> { difficulty: 'Easy' }

    // Pushing an element to an array (that doesn't exist yet) in an object:
    await db.push("userInfo.items", "Sword");
    // -> { difficulty: 'Easy', items: ['Sword'] }

    // Adding to a number (that doesn't exist yet) in an object:
    await db.add("userInfo.balance", 500);
    // -> { difficulty: 'Easy', items: ['Sword'], balance: 500 }

    // Repeating previous examples:
    await db.push("userInfo.items", "Watch");
    // -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 500 }
    await db.add("userInfo.balance", 500);
    // -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 1000 }

    // Fetching individual properties
    await db.get("userInfo.balance"); // -> 1000
    await db.get("userInfo.items"); // ['Sword', 'Watch']
})();

Example With MySQLDriver

NOTE: In order to use this driver, install npm i mysql2 separately.

const { QuickDB } = require("quick.db");
const { MySQLDriver } = require("quick.db/MySQLDriver");
(async () => {
    const mysqlDriver = new MySQLDriver({
        host: "localhost",
        user: "me",
        password: "secret",
        database: "my_db",
    });

    const db = new QuickDB({ driver: mysqlDriver });
    await db.init(); // Connects and setup the database
    // Now you can use quick.db as normal

    await db.set("userInfo", { difficulty: "Easy" });
    // -> { difficulty: 'Easy' }
})();

Example With PostgresDriver

NOTE: In order to use this driver, install npm i pg separately.

const { QuickDB } = require("quick.db");
const { PostgresDriver } = require("quick.db/PostgresDriver");
(async () => {
    const postgresDriver = new PostgresDriver({
        host: "localhost",
        user: "me",
        password: "secret",
        database: "my_db",
    });

    const db = new QuickDB({ driver: postgresDriver });
    await db.init(); // Connects and setup the database
    // Now you can use quick.db as normal

    await db.set("userInfo", { difficulty: "Easy" });
    // -> { difficulty: 'Easy' }
})();

Example With MongoDriver

NOTE: In order to use this driver, install npm i mongoose separately.

const { QuickDB } = require("quick.db");
const { MongoDriver } = require("quick.db/MongoDriver");
(async () => {
    const mongoDriver = new MongoDriver("mongodb://localhost/quickdb");

    const db = new QuickDB({ driver: mongoDriver });
    await db.init(); // Connects and setup the database
    // Now you can use quick.db as normal

    await db.set("userInfo", { difficulty: "Easy" });
    // -> { difficulty: 'Easy' }

    await mongoDriver.close();
    // disconnect from the database
})();

Example With JSONDriver

NOTE: In order to use this driver, install npm i write-file-atomic separately.

const { QuickDB } = require("quick.db");
const { JSONDriver } = require("quick.db/JSONDriver");
const jsonDriver = new JSONDriver();
const db = new QuickDB({ driver: jsonDriver });

// Init the database, this is always needed!
await db.init();
await db.set("userInfo", { difficulty: "Easy" });

Example With MemoryDriver

Note: In-memory database is not persistent and is suitable for temporary caching.

const { QuickDB } = require("quick.db");
const { MemoryDriver } = require("quick.db/MemoryDriver");
const memoryDriver = new MemoryDriver();
const db = new QuickDB({ driver: memoryDriver });

// Init the database, this is always needed!
await db.init();
await db.set("userInfo", { difficulty: "Easy" });

quick.db's People

Contributors

aidakdev avatar ashley0143 avatar cohenerickson avatar dalibortrampota avatar darkenlm avatar dependabot[bot] avatar fc5570 avatar fossabot avatar hed420 avatar hellvsparadise avatar imorfixx avatar jhr76 avatar joshiewtf avatar jtsshieh avatar lieuweberg avatar lorencerri avatar nequee avatar r-rajaneesh avatar realcartar avatar renovate[bot] avatar roni0028 avatar sijilo avatar slxca avatar stasiumdev avatar twlite avatar tysroby avatar xander1233 avatar yodalightsabr avatar zelak312 avatar zorotic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

quick.db's Issues

db.startsWith() bug

Describe the bug

When I fetch data using

db.fetch(`key_${message.guild.id}`)

I get data, however when I try to fetch data using

db.startsWith(`key_${message.guild.id}`)

in the same file I get an empty array

Example

image

Shard ?

Hello
quick.db supports sharding ?

Data Storing Conflicts

Ok so I am making a leaderboard system on my API and discord bot. While I have a leaderboard that is working fine (i.e reps, balance etc.). I have a role-play stats system where it collects data when you for example, hug a user and it works as:

This is Discord.js v11.5.1 code but is an example of the quick.db code I am using to set and add the data

  • db.add(`huggedUser_${message.mentions.users.first().id}`, 1);
  • db.set(`huggedUsername_${hugUser.id}`, message.author.username)

hugUser is the mentioned user.

Now, when fetching these with db.fetch. They fetch and display the data correctly but when using db.all().filter(data => data.ID.startsWith(`huggedUser`)).sort((a, b) => b.data - a.data); and then filtering for the leaderboard, its messed up.

You can find some examples of this happening (Using my API Service as it has a best reproduction of the error):

I guess the way to resolve this as of now is to use dot notation. but can be a bit of a setup for me to do in my bot workspace.

Can't install quick.db

Error with quick.db

Whenever I try: "npm install quick.db", it just comes up with:

PS E:\Shamurokku Discord Bot> npm i quick.db
 
> [email protected] install E:\Shamurokku Discord Bot\node_modules\integer
> prebuild-install || npm run build-release
 
'prebuild-install' is not recognized as an internal or external command,
operable program or batch file.
'npm' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `prebuild-install || npm run build-release`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
 
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\denni\AppData\Roaming\npm-cache\_logs\2020-09-01T01_40_07_262Z-debug.log

and with the debug log being this. I'd greatly appreciate any help.

.subtract () code for numbers

.subtract () code for numbers. Well how do I get the writings out?
db module is possible to add writings. But is it possible to subtract the writings? It may also be caused by my incompetence

My Code:

const db = require('quick.db')
const Discord = require('discord.js')


exports.run = async (client, message, args, config) => {

    if(message.author.id === 'My ID'){ 


    let user = message.mentions.members.first() || message.author

    if (args[0]) return message.channel.send(`${message.author}, bir eşya ismi girmen gerek!`)
    db.subtract(`${user.id}.envan`, args[0]) 
    let bal = await db.fetch(`${user.id}.envan`)

    let embed = new Discord.RichEmbed()
    .setAuthor(`Your item is received!`, message.author.displayAvatarURL)
    .addField(`Received Item:`, `${args[0]}`)
    .setColor("RED")
    .setTimestamp()
    message.channel.send(embed)
    }else{
return message.channels.send('Yetkin yok knk').then(msg => {
            setTimeout(() => {
                msg.delete()
            }, 2500);
        })
    }
}

Hard Spaces Not Working In the Sponsor Message

Describe the bug
There are hard spaces (&nbsp) in the sponsor message that show &nbsp instead of a hard space and look as if the hard space wasn't coded right and didn't work.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://quickdb.js.org/
  2. Scroll down to the footer of the page
  3. See &nbsp in the sponsor message

Expected behavior
A hard base showing instead of the &nbsp

Desktop (please complete the following information):

  • OS: macOS High Sierra
  • Browser Chrome
  • Version 77

Help!

I want to know if is there any examples, ive made a points bot but, when i do !padd @user1 23, works fine then i do !points @user1 response "23" but when i do !points @user2 response its equal than user1 that means that variable its equals to all users. (db.set ('user', {guild: message.mentions.users.first ().id, points: 0}) and db.add not working tho, it just sets a new value

Install Error

GoProstrtr44@endbot:/mnt/project/app$ npm i quick.db

[email protected] install /mnt/project/app/node_modules/integer
node-gyp rebuild

make: Entering directory '/mnt/project/app/node_modules/integer/build'
CXX(target) Release/obj.target/integer/src/integer.o
../src/integer.cpp: In static member function ‘static Result Integer::Cast(v8::Localv8::String, uint8_t)’:
../src/integer.cpp:329:33: error: no matching function for call to ‘v8::String::Value::Value(v8::Localv8::String&)’
v8::String::Value utf16(string);
^
In file included from /mnt/user/.cache/node-gyp/12.13.1/include/node/node.h:63:0,
from ../src/integer.hpp:3,
from ../src/integer.cpp:1:
/mnt/user/.cache/node-gyp/12.13.1/include/node/v8.h:3062:5: note: candidate: v8::String::Value::Value(v8::Isolate*, v8::Localv8::Value)
Value(Isolate* isolate, Localv8::Value obj);
^~~~~
/mnt/user/.cache/node-gyp/12.13.1/include/node/v8.h:3062:5: note: candidate expects 2 arguments, 1 provided
integer.target.mk:112: recipe for target 'Release/obj.target/integer/src/integer.o' failed
make: *** [Release/obj.target/integer/src/integer.o] Error 1
make: Leaving directory '/mnt/project/app/node_modules/integer/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 4.15.0-62-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /mnt/project/app/node_modules/integer
gyp ERR! node -v v12.13.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm WARN [email protected] requires a peer of @discordjs/uws@^10.149.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /mnt/user/.npm/_logs/2020-06-12T20_51_32_609Z-debug.log

.startsWith function added back

Is your feature request related to a problem? Please describe.
Yes, I have been trying to find a way to add a leaderboard.

Describe the solution you'd like
Readd the .startsWith() function

Describe alternatives you've considered
Searching google for an alternative but all I got was to loop the guild members.

Additional context
None

Outdated Documentation

I am using quick.db to store some very simple key/value pairs for a Discord bot. I noticed the documentation in readme.md and the website seem to be outdated sighting get() as the query function while in code it has been named fetch(). I could probably clean that up for you if I familiarize myself with the module enough.

I am also having issues since the fetch function seems to return a promise.

Regards,
-Garrett

Cannot find module '../build/better_sqlite3.node'

I installed quick.db on Windows.
I tried to add it to my code and when I launch my Client, I see that error :

Error: Cannot find module '../build/better_sqlite3.node'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (d:\Developpement\node_modules\better-sqlite3\lib\database.js:5:21)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

Please can you help me ?

Allow multiple "key" arguments

Is your feature request related to a problem? Please describe.
When accessing the database, I am constantly using the dot notation to access nested properties. However, this becomes a nuisance, as I often have to use a template literal to form the path (e.g. db.set(`${var1}.${var2}.${var3}`, var4);).

Describe the solution you'd like.
It would be extremely useful if the functions accepted "multiple keys" (e.g. db.set(var1, var2, var3, var4);). This would be equivalent to db.set(`${var1}.${var2}.${var3}`, var4); with the added bonus that no string manipulation has to be done and it looks a lot more readable.

Describe alternatives you've considered.
An alternative solution could be to allow an array to be passed as the "key" argument (e.g. db.set([var1, var2, var3], var4)).

Quick.db errors

So i have a version 12 discord.js bot i have used the quick.db database and now whenever i restart my bot the data seems to get lost in thin air please help me

Error: .add() data is not a number.

`
const discord = require('discord.js');
const db = require('quick.db');
const utils = require('../global/utils1.js');

  module.exports.run = async (bot, message, args) => {   

if (!message.member.hasPermission('ADMINISTRATOR')) {
    return message.reply('Nope').then(msg => {
      setTimeout(() =>{
      msg.delete()
      }, 2500)
})

}
if (!args[0]) return message.reply('Please specify an amount to add.')
if (isNaN(args[0])) return message.reply('That was not a valid number!')
let moneytoadd = args[0];
let user = message.mentions.users.first() || message.author
message.channel.send('Successfully added ' + args[0] + ' to ' + user)
db.add(money_${user.id}, moneytoadd)

}

module.exports.help = {
name: 'moneyadd',
aliases: []
};
`
That telling me that moneytoadd is not a numer but if i do console.log(moneytoadd) it shows me clearly a number

Add a "remove" function

Is your feature request related to a problem? Please describe.
I often work with arrays and as a result, I often use the .push() function. However, it becomes harder when trying to remove an item from an array, as there is no function to remove specific items.

Describe the solution you'd like.
It would be very useful if there was a remove() function that removes one or more specified values from an array (e.g. db.remove('somearray', 'aValue');). Multiple values to be removed can be specified as extra arguments (e.g. db.remove('somearray', 'aValue', 'anotherValue', 'stillGoing');).

Describe alternatives you've considered.
The function could accept an array as the second argument (e.g. db.remove('somearray', ['aValue', 'anotherValue', 'stillGoing']);) instead of extra arguments.

Help!!

I have a discord bot and i wanna make a command where i can remove premium from server
how do i do it?

Cant install module

When attempting to run npm i quick.db, i get this error

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-09-27T00_16_59_818Z-debug.log

Notes:

I am on the root account
I have already run apt-get install build-essential
I've already attempted to install integer manually via npm i [email protected] to no avail.
I'm running on Ubuntu 18.04

Error on Install

> [email protected] install /home/aseltic/Documents/QuickDB Testing/node_modules/integer
> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/aseltic/Documents/QuickDB Testing/node_modules/integer/build'
gyp ERR! System Linux 4.15.0-65-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/aseltic/Documents/QuickDB Testing/node_modules/integer
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN [email protected] requires a peer of bufferutil@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of erlpack@discordapp/erlpack but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of libsodium-wrappers@^0.7.3 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of node-opus@^0.2.7 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of opusscript@^0.0.6 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of sodium@^2.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @discordjs/uws@^10.149.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/aseltic/.npm/_logs/2019-10-11T02_03_07_904Z-debug.log

inserting author ids into an table crashes

Issue:

When you have a command and make it insert a new data in a new table it loops every user the bot has in it's cache and stores it into the database table. Resulting in sqlite3 overflooding and crashing your bot.

Steps To Reproduce:

  1. Get a new quick.db databse
  2. make a command and put in your code new db.table('test') and somewhere db.set(test_${message.author.id}, 500)
  3. execute the command
  4. Expected result: creates the database entry for the author only

Instead of the database creating only 1 entry, it loops entries for every author/user that is cached in the bot

Further Information:

  • Operating System: Linux (RaspberryPI)
  • Node.js Version: 9.11.1
  • Quick.db Version: 6.2.0
  • Any other details: Other users have the same problem as i experience

quick.dp error

(node:10568) UnhandledPromiseRejectionWarning: Error: Target is not a number.
at Object.module.exports [as subtract] (C:\Users! Parsa\Documents\PF6-- --\node_modules\quick.db\lib\subtract.js:29:36)
at arbitrate (C:\Users! Parsa\Documents\PF6-- --\node_modules\quick.db\bin\handler.js:260:25)
at Object.subtract (C:\Users! Parsa\Documents\PF6-- --\node_modules\quick.db\bin\handler.js:82:12)
at Object.module.exports.run (C:\Users! Parsa\Documents\PF6-- --\commands\Buy-Color.js:76:12)
at Client. (C:\Users! Parsa\Documents\PF6-- --\index.js:84:17)
at Client.emit (events.js:314:20)
at MessageCreateAction.handle (C:\Users! Parsa\Documents\PF6-- --\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users! Parsa\Documents\PF6-- --\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users! Parsa\Documents\PF6-- --\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users! Parsa\Documents\PF6-- --\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
(Use node --trace-warnings ... to show where the warning was created)
(node:10568) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:10568) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Suggestion: Add db.pull() method

Hi, can you please add db.pull() method?
I have data in array but i want to remove string from array.

db.push('userInfo.items', 'Watch')
// -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 500 }

For example i want to remove Sword from userInfo.items

db.pull("userInfo.items", "Sword"); 
// -> { difficulty: 'Easy', items: ['Watch'], balance: 500 }

Can you please send me example code how can i do it?

I think that db.pull() will be helpful also for others. Please add it

rejection '-'

When i try to buy something on my bot, this happens.
(node:17544) DeprecationWarning: ClientUser#setGame: use ClientUser#setActivity instead
(node:17544) UnhandledPromiseRejectionWarning: Error: Target is not a number.
at Object.module.exports [as subtract] (C:\Users\leona\OneDrive\Área de Trabalho\Piratas do Arybe\node_modules\quick.db\lib\subtract.js:29:36)
at arbitrate (C:\Users\leona\OneDrive\Área de Trabalho\Piratas do Arybe\node_modules\quick.db\bin\handler.js:260:25)
at Object.subtract (C:\Users\leona\OneDrive\Área de Trabalho\Piratas do Arybe\node_modules\quick.db\bin\handler.js:82:12)
at Object.module.exports.run (C:\Users\leona\OneDrive\Área de Trabalho\Piratas do Arybe\commands\buy.js:30:12)
at Client. (C:\Users\leona\OneDrive\Área de Trabalho\Piratas do Arybe\index.js:40:17)
at Client.emit (events.js:321:20)
at MessageCreateHandler.handle (C:\Users\leona\OneDrive\Área de Trabalho\Piratas do Arybe\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\leona\OneDrive\Área de Trabalho\Piratas do Arybe\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (C:\Users\leona\OneDrive\Área de Trabalho\Piratas do Arybe\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:\Users\leona\OneDrive\Área de Trabalho\Piratas do Arybe\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
(node:17544) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:17544) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.<

Getting errors on run.

I get this error when I run my code
I've used quick.db before and everything has gone fine I don't know what the issue is now

C:\node_modules\quick.db\bin\handler.js:240
db.prepare(CREATE TABLE IF NOT EXISTS ${options.table} (ID TEXT, json TEXT)).run();
^
SqliteError: file is not a database

Webview!

I would like the Webview from 6.1.1 back. This may sound petty but hey, it was a nice feature!

help!!!

so i have a bot called asuna V2 and i made a setpremium command for setting a server premium.
and i made a pstatus to check if the server is premium
const Discord = require("discord.js");
const db = require("quick.db");

module.exports.run = async(client, message, args) => {
const guild = db.fetch(premium_${message.guild.id})
if(!guild) {
message.channel.send(This server is premium)
}else{
message.channel.send(This server is not a ***PREMIUM*** server. If you want to buy contact the dev's.);
}
}
why is not working?
the server that is premium. its telling its not premium?
why?

Please help

npm ERR! Failed at the [email protected] install script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Users\Lucatrio\AppData\Roaming\npm-cache_logs\2018-08-11T22_06_25_201Z-debug.log

Node Gyp errors

Describe the bug
I'm not able to install quick.db
To Reproduce
Steps to reproduce the behavior:
After following all the steps in the windows tutorial, run: npm i quick.db

Expected behavior
I want it to install without any errors. :|
Screenshots
If applicable, add screenshots to help explain your problem.

Desktop:

  • OS: Windows 10
  • Node: 12.18.2
  • Npm: 6.14.7

Additional context
Add any other context about the problem here.

This is the full error:

C:\Users\noahg>npm install quick.db

> [email protected] install C:\Users\noahg\node_modules\integer
> prebuild-install || npm run build-release

prebuild-install WARN install No prebuilt binaries found (target=12.18.2 runtime=node arch=x64 libc= platform=win32)

> [email protected] build-release C:\Users\noahg\node_modules\integer
> node-gyp rebuild --release


C:\Users\noahg\node_modules\integer>if not defined npm_config_node_gyp (node "C:\Users\noahg\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild --release )  else (node "C:\Users\noahg\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild --release )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  integer.cpp
  win_delay_load_hook.cc
c:\users\noahg\node_modules\integer\src\integer.cpp(370): warning C4804: '-': unsafe use of type 'bool' in operation [C:\Users\noahg\node_modules\integer\build\integer.vcxproj]
C:\\Users\\noahg\\AppData\\Local\\node-gyp\\Cache\\12.18.2\\x64\\node.lib : fatal error LNK1106: invalid file or disk full: cannot seek to 0x2FCF10 [C:\Users\noahg\node_modules\integer\build\integ
er.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\noahg\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Windows_NT 10.0.19041
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\noahg\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--release"
gyp ERR! cwd C:\Users\noahg\node_modules\integer
gyp ERR! node -v v12.18.2
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build-release: `node-gyp rebuild --release`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build-release script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\noahg\AppData\Roaming\npm-cache\_logs\2020-07-31T20_27_50_999Z-debug.log
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\noahg\package.json'
npm WARN noahg No description
npm WARN noahg No repository field.
npm WARN noahg No README data
npm WARN noahg No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `prebuild-install || npm run build-release`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\noahg\AppData\Roaming\npm-cache\_logs\2020-07-31T20_30_47_021Z-debug.log

Cant install quick.db on Ubuntu

Describe the bug
A clear and concise description of what the bug is.

Whenever I go to install quick.db on my ubuntu root server it shoots out this error:
`> [email protected] install /root/osrp_bot/node_modules/integer

node-gyp rebuild

gyp ERR! build error
gyp ERR! stack Error: not found: make
gyp ERR! stack at getNotFoundError (/usr/lib/node_modules/npm/node_modules/which/which.js:13:12)
gyp ERR! stack at F (/usr/lib/node_modules/npm/node_modules/which/which.js:68:19)
gyp ERR! stack at E (/usr/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/isexe/index.js:42:5
gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Linux 4.9.0-4-amd64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/osrp_bot/node_modules/integer
gyp ERR! node -v v8.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok`

To Reproduce
Steps to reproduce the behavior:

  1. Attempt to install quick.db with 'npm install quick.db' on an ubuntu server
  2. See error

Expected behavior
A clear and concise description of what you expected to happen.
Quick.db will install correctly and be ready for use with Nodejs and NPM

Screenshots
If applicable, add screenshots to help explain your problem.
N/A (All evidence provided above)

Desktop (please complete the following information):

  • OS: [e.g. iOS] Debian 9 64bit Minimal
  • Browser [e.g. chrome, safari] N/A
  • Version [e.g. 22] V9

Smartphone (please complete the following information):
N/A

Additional context
Add any other context about the problem here.
I noticed that error is similiar to the error given on windows.
However, there is no written fix for this problem on Ubuntu

Quick.db not installing

Whenever i try to install quick.db it never installes and shows this error

I have also installed the windows build tools and followed all the steps on how to install

error:
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\Ayan\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Ayan\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--release"
gyp ERR! cwd C:\Users\Ayan\Desktop\Ayan Folders\ICS-Helper\node_modules\integer
gyp ERR! node -v v12.18.2
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build-release: node-gyp rebuild --release
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build-release script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ayan\AppData\Roaming\npm-cache_logs\2020-08-29T06_43_04_234Z-debug.log
npm WARN [email protected] requires a peer of discord.js@^11.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of sqlite@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of better-sqlite3@^7.1.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: prebuild-install || npm run build-release
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ayan\AppData\Roaming\npm-cache_logs\2020-08-29T06_43_06_836Z-debug.log

HELP fixing the error

(node:3557) UnhandledPromiseRejectionWarning: TypeError: db.startsWith is not a function
Getting this error on glitch hosting
Discord.js version 11.5
Quick.db version 7.1.1
Node version 12.x

Updating a value adds double quotes.

Issue:

If you update a value with db.set('...', 'New Value', { target: '.item' })`, it adds double quotes to the current quotes.

Steps To Reproduce:

  1. Create a new row with db.set('name', { item1: 'Value1', item2: 'Value2' })
  2. Change a value, for example item1; db.set('name', 'New Value1', { target: '.item1' })
  3. Log the row, see that double quotes are added to the existing ones.

Installation Issues:

We are aware of some installation issues regarding better-sqlite3, although we are still working to find methods of installation for each platform.

Further Information:

  • Operating System: Unknown
  • Node.js Version: 8.9.4
  • Quick.db Version: 5.4.13
  • Any other details: -

Template: (While you are not required to follow this, it is recommended)

  • Issue: See above.

  • Steps To Reproduce: Above.

  • Versions (Node.js, Quick.db): Above.

  • What Have You Tried? -

  • Any Additional Details: -

Questions

1. Any benchmarks of this db?
like qucik.db vs rethinkdb vs redis vs mysql or something?

2. Does this database limit me to any space? or its unlimited, and db will not do stuff like corruption, being slow etc?

3. Is this database fast?

4. Will it be fast on bot for example with 20k servers, 20 shards, and high load?

quick.db showing error

Expected behavior
run without error

Screenshots
getting this error

C:\Users\..\Desktop\AvaBot>npm i quick.db
+ quick.db@7.1.1
updated 1 package and audited 340 packages in 10.753s

18 packages are looking for funding
  run `npm fund` for details

found 1 low severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details

C:\Users\..\Desktop\AvaBot>npm audit

                       === npm audit security report ===                        


                                 Manual Review                                  
             Some vulnerabilities require your attention to resolve             
                                                                                
          Visit https://go.npm.me/audit-guide for additional guidance           


  Low             Prototype Pollution                                           

  Package         lodash                                                        

  Patched in      >=4.17.19                                                     

  Dependency of   quick.db                                                      

  Path            quick.db > lodash                                             

  More info       https://npmjs.com/advisories/1523                             

found 1 low severity vulnerability in 340 scanned packages
  1 vulnerability requires manual review. See the full report for details.```

**Desktop (please complete the following information):**
 - OS: windows 10
 - Browser chrome

Allow users to specify the database location.

Is your feature request related to a problem? Please describe.
Running Discord bots, for example, require that you run said bot from the same folder each time. If you were to run it from your home directory for example, a new json.sqlite file would be created there, and the bot would read an empty database. Not only can this be extremely frustrating trying to debug things from within other folders, but makes CLI applications using quick.db completely unusable.

Describe the solution you'd like
I'd like to have the ability to specify an absolute path in the require method.

Describe alternatives you've considered
I've only considered switching to a more 'proper' database tool, however for small projects, this is an amazing time saver and I'd love to continue using it.

Additional context
N/a

Table name as a db option

Is your feature request related to a problem? Please describe.
I would like to insert data on a specific table without needing to create a table object.

Describe the solution you'd like
We know that db.table() is a simple wrapper that fixes a tableName to arbitrate(). I would like to send tableName as an option from any db function. For example:

db.set('value', 'data in json table')
db.get('value') // 'data in json table'

let table = new db.table('test')
table.set('value', 'data in test table')
table.get('value') // 'data in test table'

// I want this to be possible
db.get('value', { tableName: 'test' }) // 'data in test table'

// but since it's not implemented, this is what happens
db.get('value', { tableName: 'test' }) // 'data in json table'

Describe alternatives you've considered
I've considered forking and adding this feature myself.

Additional context
None.

Cant install quick.db on Ubuntu 18 using pterodactyl panel

Hi, Ive been using quick.db on my pc for a while to store data in my bot. Ive recently bought a vps and installed pterodactyl to host my bot. It never installs so i try and adding the quickdb module in my node_module directory but then it says theres no better_sqlite3 even though its in node_modules. If you could please help me, thanks.

.push doesn't create an array when a string only contains numbers, instead it converts the string to a number

Describe the bug
Pushing a string that only contains numbers (ex: "12345) with .push will not create a array, instead it will convert the string to a number, setting the value of the db to an array before won't fix it either.

To Reproduce
Steps to reproduce the behavior:

db.push('test', '123434324234')
console.log(db.get('test'))
console.log(typeof db.get('test')) // number

or

db.set('test', [])
db.push('test', '123434324234')
console.log(db.get('test'))
console.log(typeof db.get('test')) // number

Expected behavior
It should create an array and push the string into it without converting it to a number.

Screenshots
Capture
image

Desktop (please complete the following information):

  • OS: Windows 10
  • quick.db Version: 7.1.1

Installing

npm ERR! Unexpected end of JSON input while parsing near '...lodash/-/lodash-4.9.0'

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\VeryAnonymousUser\AppData\Roaming\npm-cache_logs\2020-08-18T12_50_29_836Z-debug.log

Suggestion

Is your feature request related to a problem? Please describe.
I like databases that has web panel (like rethink db) its cool

Describe the solution you'd like
Support of starting web panel/dashboard or something like that, that shows for example, reads/s, writes/s tables, tables that has issues/problems etc.

Describe alternatives you've considered
CLI panel

Additional context
Support for binding to localhost:port

TypeError: db.updateText is not a function

Making a bot called VerifyBot that protects users from spam bots.

Only problem is this:

C:\Users\justi\STORAGE\6th\VerifyBot\index.js:25
        db.updateText(`messageChannel_${message.guild.id}`, newChannel).then(i => {
           ^

TypeError: db.updateText is not a function
    at Client.client.on (C:\Users\justi\STORAGE\6th\VerifyBot\index.js:25:12)
    at Client.emit (events.js:198:13)
    at MessageCreateHandler.handle (C:\Users\justi\STORAGE\6th\VerifyBot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (C:\Users\justi\STORAGE\6th\VerifyBot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
    at WebSocketConnection.onPacket (C:\Users\justi\STORAGE\6th\VerifyBot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:330:35)
    at WebSocketConnection.onMessage (C:\Users\justi\STORAGE\6th\VerifyBot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:293:17)
    at WebSocket.onMessage (C:\Users\justi\STORAGE\6th\VerifyBot\node_modules\ws\lib\EventTarget.js:99:16)
    at WebSocket.emit (events.js:198:13)
    at Receiver._receiver.onmessage (C:\Users\justi\STORAGE\6th\VerifyBot\node_modules\ws\lib\WebSocket.js:141:47)
    at Receiver.dataMessage (C:\Users\justi\STORAGE\6th\VerifyBot\node_modules\ws\lib\Receiver.js:389:14)

Yeah, some help?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.